1 /*
2  * Copyright (c) 2003, Intel Corporation. All rights reserved.
3  * Created by:  salwan.searty 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  Steps:
9  1. Set up a handler for signal SIGABRT, such that it is called if signal is ever raised.
10  2. Call sighold on that SIGABRT.
11  3. Raise a SIGABRT and verify that the signal handler was not called.
12 
13 */
14 
15 #define _XOPEN_SOURCE 600
16 
17 #include <signal.h>
18 #include <stdio.h>
19 #include <unistd.h>
20 #include "posixtest.h"
21 
22 static int handler_called = 0;
23 
handler(int signo)24 static void handler(int signo)
25 {
26 	handler_called = 1;
27 }
28 
main(void)29 int main(void)
30 {
31 	struct sigaction act;
32 
33 	act.sa_handler = handler;
34 	act.sa_flags = 0;
35 	sigemptyset(&act.sa_mask);
36 	if (sigaction(SIGABRT, &act, 0) == -1) {
37 		perror("Unexpected error while attempting to setup test "
38 		       "pre-conditions");
39 		return PTS_UNRESOLVED;
40 	}
41 
42 	if (sighold(SIGABRT) == -1) {
43 		perror("Unexpected error while attempting to setup test "
44 		       "pre-conditions");
45 		return PTS_UNRESOLVED;
46 	}
47 
48 	if (raise(SIGABRT) == -1) {
49 		perror("Unexpected error while attempting to setup test "
50 		       "pre-conditions");
51 		return PTS_UNRESOLVED;
52 	}
53 
54 	usleep(100000);
55 
56 	if (handler_called) {
57 		printf("FAIL: Signal was not blocked\n");
58 		return PTS_FAIL;
59 	}
60 
61 	printf("Test PASSED: signal was blocked\n");
62 	return PTS_PASS;
63 }
64