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 the lowest pending signal will be 9 selected by sigwaitinfo() if there are any multiple pending signals in the 10 range SIGRTMIN to SIGRTMAX. 11 12 Steps: 13 - Register for myhandler to be called when any signal between SIGRTMIN 14 and SIGRTMAX is generated, and make sure SA_SIGINFO is set. 15 - Also, make sure that all of these signals are added to the set that 16 will be passed to sigwaitinfo(). 17 - Block all of these signals from the process. 18 - Raise all of these signals using sigqueue. 19 - call sigwaitinfo() and verify that it returns SIGRTMIN 20 */ 21 22#define _XOPEN_SOURCE 600 23#define _XOPEN_REALTIME 1 24 25#include <signal.h> 26#include <stdio.h> 27#include <unistd.h> 28#include <stdlib.h> 29#include <errno.h> 30#include "posixtest.h" 31 32 33void myhandler(int signo, siginfo_t *info, void *context) { 34 printf ("Inside dummy handler\n"); 35} 36 37int main() 38{ 39 int pid, rtsig; 40 union sigval value; 41 struct sigaction act; 42 sigset_t selectset; 43 44 act.sa_flags = SA_SIGINFO; 45 act.sa_sigaction = myhandler; 46 sigemptyset(&act.sa_mask); 47 sigemptyset(&selectset); 48 49 for (rtsig=SIGRTMAX; rtsig>=SIGRTMIN; rtsig--) { 50 sigaddset(&act.sa_mask, rtsig); 51 sighold(rtsig); 52 sigaddset(&selectset, rtsig); 53 } 54 55 pid = getpid(); 56 value.sival_int = 5; /* 5 is just an arbitrary value */ 57 58 for (rtsig=SIGRTMAX; rtsig>=SIGRTMIN; rtsig--) { 59 sigaction(rtsig, &act, 0); 60 if (sigqueue(pid, rtsig, value) != 0) { 61 printf("Test UNRESOLVED: call to sigqueue did not return success\n"); 62 return PTS_UNRESOLVED; 63 } 64 } 65 66 if (sigwaitinfo(&selectset, NULL) != SIGRTMIN) { 67 printf("Test FAILED: sigwaitinfo() did not return the lowest of the multiple pending signals between SIGRTMIN and SIGRTMAX\n"); 68 return PTS_FAIL; 69 } 70 71 return PTS_PASS; 72} 73 74