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 Go through all the signals (with the exception of SIGKILL and SIGSTOP
10 since they cannot be added to a process's signal mask) and add each one
11 to the signal mask. Every time a signal gets added to the signal mask
12 (using the sigprocmask() function), make sure that all signals added
13 before it in preceding iterations before it, exist in the old signal set
14 returned by the sigprocmask functions.
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
main(void)24 int main(void)
25 {
26 sigset_t oactl, tempset;
27 int i, j, test_failed = 0;
28
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 for (i = 0; i < NUMSIGNALS; i++) {
45 sigemptyset(&oactl);
46 sigemptyset(&tempset);
47 sigaddset(&tempset, siglist[i]);
48 sigprocmask(SIG_BLOCK, &tempset, &oactl);
49 if (i > 0) {
50 for (j = 0; j < i; j++) {
51 if (sigismember(&oactl, siglist[j]) != 1) {
52 test_failed = 1;
53 }
54 }
55 }
56 }
57
58 if (test_failed != 0) {
59 printf("Old set is missing a signal\n");
60 return PTS_FAIL;
61 }
62
63 printf
64 ("Test PASSED: oactl did contain all signals that were added to the signal mask.\n");
65 return PTS_PASS;
66 }
67