• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
3  * Created by:  julie.n.fleischer 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  *  Test that the sigpending() function returns 0 on successful completion.
9  *  1)  Block one signal from delivery.
10  *  2)  Raise that signal.
11  *  3)  Call sigpending and verify it returns 0.
12  *  4)  Verify the signal raised is shown.
13  */
14 
15 #include <signal.h>
16 #include <stdio.h>
17 #include "posixtest.h"
18 
main(void)19 int main(void)
20 {
21 	sigset_t blockset;
22 	sigset_t prevset;
23 	sigset_t pendingset;
24 
25 	if ((sigemptyset(&blockset) == -1) ||
26 	    (sigemptyset(&prevset) == -1) || (sigemptyset(&pendingset) == -1)) {
27 		printf("Could not call sigemptyset()\n");
28 		return PTS_UNRESOLVED;
29 	}
30 
31 	if (sigaddset(&blockset, SIGUSR2) == -1) {
32 		perror("Error calling sigaddset()\n");
33 		return PTS_UNRESOLVED;
34 	}
35 
36 	if (sigprocmask(SIG_SETMASK, &blockset, &prevset) == -1) {
37 		printf("Could not call sigprocmask()\n");
38 		return PTS_UNRESOLVED;
39 	}
40 
41 	if (raise(SIGUSR2) != 0) {
42 		printf("Could not raise SIGUSR2\n");
43 		return PTS_UNRESOLVED;
44 	}
45 
46 	if (sigpending(&pendingset) == 0) {
47 		if (sigismember(&pendingset, SIGUSR2) == 1) {
48 			printf("sigpending returned 0 when successful\n");
49 			printf("Test PASSED\n");
50 			return PTS_PASS;
51 		} else {
52 			printf("sigpending returned 0 when unsuccessful\n");
53 			printf("Test FAILED\n");
54 			return PTS_FAIL;
55 		}
56 	} else {
57 		printf("sigpending did not return 0\n");
58 		printf("Test FAILED\n");
59 		return PTS_FAIL;
60 	}
61 
62 	return PTS_UNRESOLVED;
63 }
64