• 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  This program tests the assertion that if the info parameter is not NULL,
9  then the selected signal number shall be stored in the si_signo member.
10 
11  1. Register signal SIGTOTEST with the handler myhandler.
12  2. Block signal SIGTOTEST, and then raise it causing it to become pending.
13  3. Call sigwaitinfo() with only SIGTOTEST in set.
14  4. Verify that info.si_signo equals SIGTOTEST.
15 
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,siginfo_t * info,void * context)28 void myhandler(int signo, siginfo_t * info, void *context)
29 {
30 	printf("Inside handler\n");
31 }
32 
main(void)33 int main(void)
34 {
35 
36 	struct sigaction act;
37 
38 	sigset_t selectset;
39 	siginfo_t info;
40 
41 	act.sa_flags = SA_SIGINFO;
42 	act.sa_sigaction = myhandler;
43 
44 	sigemptyset(&selectset);
45 	sigaddset(&selectset, SIGTOTEST);
46 
47 	sigemptyset(&act.sa_mask);
48 	sigaction(SIGTOTEST, &act, 0);
49 	sighold(SIGTOTEST);
50 
51 	raise(SIGTOTEST);
52 
53 	if (sigwaitinfo(&selectset, &info) == -1) {
54 		perror("Call to sigwaitinfo() failed\n");
55 		return PTS_UNRESOLVED;
56 	}
57 
58 	if (info.si_signo != SIGTOTEST) {
59 		printf("Test FAILED: The selected signal number hasn't been"
60 		       "stored in the si_signo member.\n");
61 		return PTS_FAIL;
62 	}
63 
64 	printf("Test PASSED\n");
65 	return PTS_PASS;
66 }
67