1/*
2 * Copyright (c) 2002, Intel Corporation. All rights reserved.
3 * Created by:  julie.n.fleischer REMOVE-THIS AT intel DOT com
4 * This file is licensed under the GPL license.  For the full content
5 * of this license, see the COPYING file at the top level of this
6 * source tree.
7
8 *  Test that the raise(<signal>) function shall send the signal
9 *  to the executing process.
10 *  1) Set up a signal handler for the signal that says we have caught the
11 *     signal.
12 *  2) Raise the signal.
13 *  3) If signal handler was called, test passed.
14 *  This test is only performed on one signal.  All other signals are
15 *  considered to be in the same equivalence class.
16 */
17
18#include <signal.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include "posixtest.h"
22
23#define SIGTOTEST SIGABRT
24
25void handler(int signo)
26{
27	printf("Caught signal being tested!\n");
28	printf("Test PASSED\n");
29	exit(0);
30}
31
32int main()
33{
34	struct sigaction act;
35
36	act.sa_handler=handler;
37	act.sa_flags=0;
38	if (sigemptyset(&act.sa_mask) == -1) {
39		perror("Error calling sigemptyset\n");
40		return PTS_UNRESOLVED;
41	}
42	if (sigaction(SIGTOTEST, &act, 0) == -1) {
43		perror("Error calling sigaction\n");
44		return PTS_UNRESOLVED;
45	}
46	if (raise(SIGTOTEST) != 0) {
47		printf("Could not raise signal being tested\n");
48		return PTS_FAIL;
49	}
50
51	printf("Should have exited from signal handler\n");
52	printf("Test FAILED\n");
53	return PTS_FAIL;
54}
55
56