• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include <signal.h>
17 #include <stdio.h>
18 #include <time.h>
19 #include <unistd.h>
20 #include "posixtest.h"
21 
22 static int handler_called = 0;
23 
handler(int signo PTS_ATTRIBUTE_UNUSED)24 static void handler(int signo PTS_ATTRIBUTE_UNUSED)
25 {
26 	handler_called = 1;
27 }
28 
main(void)29 int main(void)
30 {
31 	struct sigaction act;
32 	struct timespec signal_wait_ts = {0, 100000000};
33 
34 	act.sa_handler = handler;
35 	act.sa_flags = 0;
36 	sigemptyset(&act.sa_mask);
37 	if (sigaction(SIGABRT, &act, 0) == -1) {
38 		perror("Unexpected error while attempting to setup test "
39 		       "pre-conditions");
40 		return PTS_UNRESOLVED;
41 	}
42 
43 	if (sighold(SIGABRT) == -1) {
44 		perror("Unexpected error while attempting to setup test "
45 		       "pre-conditions");
46 		return PTS_UNRESOLVED;
47 	}
48 
49 	if (raise(SIGABRT) == -1) {
50 		perror("Unexpected error while attempting to setup test "
51 		       "pre-conditions");
52 		return PTS_UNRESOLVED;
53 	}
54 
55 	nanosleep(&signal_wait_ts, NULL);
56 
57 	if (handler_called) {
58 		printf("FAIL: Signal was not blocked\n");
59 		return PTS_FAIL;
60 	}
61 
62 	printf("Test PASSED: signal was blocked\n");
63 	return PTS_PASS;
64 }
65