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_SOURCE 600
19#define _XOPEN_REALTIME 1
20#define SIGTOTEST SIGUSR1
21
22#include <signal.h>
23#include <stdio.h>
24#include <stdlib.h>
25#include <unistd.h>
26#include <sys/wait.h>
27#include "posixtest.h"
28
29void myhandler(int signo, siginfo_t * info, void *context)
30{
31	printf("Inside handler\n");
32}
33
34int main(void)
35{
36
37	struct sigaction act;
38
39	sigset_t selectset;
40	siginfo_t info;
41
42	act.sa_flags = SA_SIGINFO;
43	act.sa_sigaction = myhandler;
44
45	sigemptyset(&selectset);
46	sigaddset(&selectset, SIGTOTEST);
47
48	sigemptyset(&act.sa_mask);
49	sigaction(SIGTOTEST, &act, 0);
50	sighold(SIGTOTEST);
51
52	raise(SIGTOTEST);
53
54	if (sigwaitinfo(&selectset, &info) == -1) {
55		perror("Call to sigwaitinfo() failed\n");
56		return PTS_UNRESOLVED;
57	}
58
59	if (info.si_signo != SIGTOTEST) {
60		printf("Test FAILED: The selected signal number hasn't been"
61		       "stored in the si_signo member.\n");
62		return PTS_FAIL;
63	}
64
65	printf("Test PASSED\n");
66	return PTS_PASS;
67}
68