• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
3  * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz>
4  *
5  * Created by:  julie.n.fleischer REMOVE-THIS AT intel DOT com
6  * This file is licensed under the GPL license.  For the full content
7  * of this license, see the COPYING file at the top level of this
8  * source tree.
9  *
10  * Test that sigdelset() will remove signo to the set signal set.
11  * Test steps:
12  * 1)  Initialize an empty or full signal set.
13  * 2)  Add the SIGALRM signal to the empty signal set.
14  * 3)  Verify that SIGALRM is a member of the signal set.
15  * 4)  Remove the SIGALRM signal from the signal set.
16  * 5)  Verify that SIGALRM is not a member of the signal set.
17  */
18 #include <stdio.h>
19 #include <signal.h>
20 #include "posixtest.h"
21 
main(void)22 int main(void)
23 {
24 	sigset_t signalset;
25 
26 	if (sigemptyset(&signalset) == -1) {
27 		perror("sigemptyset failed -- test aborted");
28 		return PTS_UNRESOLVED;
29 	}
30 
31 	if (sigaddset(&signalset, SIGALRM) == -1) {
32 		printf("sigaddset did not successfully add signal\n");
33 		return PTS_UNRESOLVED;
34 	}
35 
36 	if (sigismember(&signalset, SIGALRM) != 1) {
37 		printf("sigismember failed\n");
38 		return PTS_UNRESOLVED;
39 	}
40 
41 	if (sigdelset(&signalset, SIGALRM) == -1) {
42 		printf("sigdelset() failed\n");
43 		return PTS_FAIL;
44 	}
45 
46 	if (sigismember(&signalset, SIGALRM) == 0) {
47 		printf("Test PASSED: sigdelset successfully removed signal\n");
48 		return PTS_PASS;
49 	} else {
50 		printf("Signal is still in signal set.\n");
51 		return PTS_FAIL;
52 	}
53 }
54