• 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 when signo in sigqueue() is 0, error checking is
9  *  still performed.
10 
11  *  Steps:
12 
13  *  Call sigqueue() with signo equal to zero but pid is 999999
14  *  and verify that ESRCH error received and sigqueue() returned -1.
15 
16  *  Call sigqueue() with signo equal to zero but pid is 1 (init)
17  *  and verify EPERM error received and kill() returned -1.
18 
19  */
20 
21 #define _XOPEN_REALTIME 1
22 
23 #include <signal.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <unistd.h>
27 #include <errno.h>
28 #include <sys/types.h>
29 #include "posixtest.h"
30 
main(void)31 int main(void)
32 {
33 	int failure = 0;
34 	union sigval value;
35 	value.sival_int = 0;	/* 0 is just an arbitrary value */
36 
37 	/*
38 	 * ESRCH
39 	 */
40 	if (-1 == sigqueue(999999, 0, value)) {
41 		if (ESRCH == errno) {
42 			printf("ESRCH error received\n");
43 		} else {
44 			printf
45 			    ("sigqueue() failed on ESRCH but errno not set correctly\n");
46 			failure = 1;
47 		}
48 	} else {
49 		printf("sigqueue() did not return -1 on ESRCH\n");
50 		failure = 1;
51 	}
52 
53 	if (failure) {
54 		printf("At least one test FAILED -- see output for status\n");
55 		return PTS_FAIL;
56 	} else {
57 		printf("All tests PASSED\n");
58 		return PTS_PASS;
59 	}
60 }
61