• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 
3  * Copyright (c) 2003, Intel Corporation. All rights reserved.
4  * Created by:  salwan.searty REMOVE-THIS AT intel DOT com
5  * This file is licensed under the GPL license.  For the full content
6  * of this license, see the COPYING file at the top level of this
7  * source tree.
8 
9  Steps:
10  1. Add only SIGABRT to the signal mask.
11  2. Make a call such as this: sigprocmask(SIG_BLOCK, NULL, &oactl). At
12  this point, we have obtained the signal mask in oactl.
13  3. Now call is_changed to make sure that SIGABRT is still in oactl, and
14  that no other signal in the set is in oactl.
15 
16 */
17 
18 #include <signal.h>
19 #include <stdio.h>
20 #include "posixtest.h"
21 
22 #define NUMSIGNALS (sizeof(siglist) / sizeof(siglist[0]))
23 
is_changed(sigset_t set,int sig)24 int is_changed(sigset_t set, int sig)
25 {
26 
27 	int i;
28 	int siglist[] = { SIGABRT, SIGALRM, SIGBUS, SIGCHLD,
29 		SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT,
30 		SIGPIPE, SIGQUIT, SIGSEGV,
31 		SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU,
32 		SIGUSR1, SIGUSR2,
33 #ifdef SIGPOLL
34 		SIGPOLL,
35 #endif
36 #ifdef SIGPROF
37 		SIGPROF,
38 #endif
39 		SIGSYS,
40 		SIGTRAP, SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ
41 	};
42 
43 	if (sigismember(&set, sig) != 1) {
44 		return 1;
45 	}
46 	for (i = 0; i < (int)NUMSIGNALS; i++) {
47 		if ((siglist[i] != sig)) {
48 			if (sigismember(&set, siglist[i]) != 0) {
49 				return 1;
50 			}
51 		}
52 	}
53 	return 0;
54 }
55 
main(void)56 int main(void)
57 {
58 	sigset_t actl, oactl;
59 
60 	sigemptyset(&actl);
61 	sigemptyset(&oactl);
62 
63 	sigaddset(&actl, SIGABRT);
64 
65 	sigprocmask(SIG_SETMASK, &actl, NULL);
66 	sigprocmask(SIG_BLOCK, NULL, &oactl);
67 
68 	if (is_changed(oactl, SIGABRT))
69 		return PTS_FAIL;
70 
71 	printf("Test PASSED: signal mask was not changed.\n");
72 	return PTS_PASS;
73 }
74