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 sigtimedwait() function shall return the selected signal 9 number upon success. 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 sigtimedwait() and verify that it returns the signal SIGTOTEST. 16 */ 17 18#define _XOPEN_SOURCE 600 19#define _XOPEN_REALTIME 1 20#define SIGTOTEST SIGUSR1 21 22#include <sys/wait.h> 23#include <signal.h> 24#include <stdio.h> 25#include <stdlib.h> 26#include <time.h> 27#include <unistd.h> 28#include "posixtest.h" 29 30void myhandler(int signo) 31{ 32 printf("Inside handler\n"); 33} 34 35int main(void) 36{ 37 38 struct sigaction act; 39 sigset_t pendingset, selectset; 40 struct timespec ts; 41 42 act.sa_flags = 0; 43 act.sa_handler = myhandler; 44 45 ts.tv_sec = 0; 46 ts.tv_nsec = 0; 47 48 sigemptyset(&pendingset); 49 sigemptyset(&selectset); 50 sigaddset(&selectset, SIGTOTEST); 51 sigemptyset(&act.sa_mask); 52 53 sigaction(SIGTOTEST, &act, 0); 54 sighold(SIGTOTEST); 55 raise(SIGTOTEST); 56 57 sigpending(&pendingset); 58 59 if (sigismember(&pendingset, SIGTOTEST) != 1) { 60 perror("SIGTOTEST is not pending\n"); 61 return PTS_UNRESOLVED; 62 } 63 64 if (sigtimedwait(&selectset, NULL, &ts) != SIGTOTEST) { 65 perror("Call to sigtimedwait() failed\n"); 66 return PTS_FAIL; 67 } 68 69 printf("Test PASSED\n"); 70 return PTS_PASS; 71} 72