• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2002-2003, Intel Corporation. All rights reserved.
3  * Created by:  salwan.searty 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 sigwaitinfo() function shall return the selected signal
9     number.
10 
11     Steps:
12     1. Register signal SIGTOTEST with the handler myhandler
13     2. Block SIGTOTEST from the process
14     3. Raise the signal, causing it to be pending
15     4. Call sigwaitinfo() and verify that it returns the signal SIGTOTEST.
16  */
17 
18 #define _XOPEN_REALTIME 1
19 #define SIGTOTEST SIGUSR1
20 
21 #include <signal.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <sys/wait.h>
26 #include "posixtest.h"
27 
myhandler(int signo PTS_ATTRIBUTE_UNUSED)28 static void myhandler(int signo PTS_ATTRIBUTE_UNUSED)
29 {
30 	printf("Inside handler\n");
31 }
32 
main(void)33 int main(void)
34 {
35 
36 	struct sigaction act;
37 	sigset_t pendingset, selectset;
38 
39 	act.sa_flags = 0;
40 	act.sa_handler = myhandler;
41 
42 	sigemptyset(&pendingset);
43 	sigemptyset(&selectset);
44 	sigaddset(&selectset, SIGTOTEST);
45 	sigemptyset(&act.sa_mask);
46 
47 	sigaction(SIGTOTEST, &act, 0);
48 	sighold(SIGTOTEST);
49 	raise(SIGTOTEST);
50 
51 	sigpending(&pendingset);
52 
53 	if (sigismember(&pendingset, SIGTOTEST) != 1) {
54 		perror("SIGTOTEST is not pending\n");
55 		return PTS_UNRESOLVED;
56 	}
57 
58 	if (sigwaitinfo(&selectset, NULL) != SIGTOTEST) {
59 		perror("Call to sigwaitinfo() failed\n");
60 		return PTS_FAIL;
61 	}
62 
63 	printf("Test PASSED\n");
64 	return PTS_PASS;
65 }
66