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_SETMASK, NULL, &oactl).
12 At
13 this point, we have obtained the signal mask in oactl.
14 3. Now call is_changed to make sure that SIGABRT is still in oactl, and
15 that no other signal in the set is in oactl.
16
17 */
18
19 #include <signal.h>
20 #include <stdio.h>
21 #include "posixtest.h"
22
23 #define NUMSIGNALS (sizeof(siglist) / sizeof(siglist[0]))
24
is_changed(sigset_t set,int sig)25 int is_changed(sigset_t set, int sig)
26 {
27
28 int i;
29 int siglist[] = { SIGABRT, SIGALRM, SIGBUS, SIGCHLD,
30 SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT,
31 SIGPIPE, SIGQUIT, SIGSEGV,
32 SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU,
33 SIGUSR1, SIGUSR2,
34 #ifdef SIGPOLL
35 SIGPOLL,
36 #endif
37 #ifdef SIGPROF
38 SIGPROF,
39 #endif
40 SIGSYS,
41 SIGTRAP, SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ
42 };
43
44 if (sigismember(&set, sig) != 1) {
45 return 1;
46 }
47 for (i = 0; i < NUMSIGNALS; i++) {
48 if ((siglist[i] != sig)) {
49 if (sigismember(&set, siglist[i]) != 0) {
50 return 1;
51 }
52 }
53 }
54 return 0;
55 }
56
main(void)57 int main(void)
58 {
59 sigset_t actl, oactl;
60
61 sigemptyset(&actl);
62 sigemptyset(&oactl);
63
64 sigaddset(&actl, SIGABRT);
65
66 sigprocmask(SIG_SETMASK, &actl, NULL);
67 sigprocmask(SIG_SETMASK, NULL, &oactl);
68
69 if (is_changed(oactl, SIGABRT))
70 return PTS_FAIL;
71
72 printf("Test PASSED: signal mask was not changed.\n");
73 return PTS_PASS;
74 }
75