1 /* 2 * Copyright (c) 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 function shall be executed 9 when the signal occurs if the disp parameter is the address of a function. 10 11 How this program tests this assertion is by setting up a handler 12 "myhandler" for SIGCHLD, and then raising that signal. If the 13 handler_called variable is anything but 1, then fail, otherwise pass. 14 15 */ 16 17 #define _XOPEN_SOURCE 600 18 19 #include <signal.h> 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include "posixtest.h" 23 24 int handler_called = 0; 25 26 void myhandler(int signo) 27 { 28 printf("SIGCHLD called. Inside handler\n"); 29 handler_called = 1; 30 } 31 32 int main(void) 33 { 34 if (sigset(SIGCHLD, myhandler) == SIG_ERR) { 35 perror("Unexpected error while using sigset()"); 36 return PTS_UNRESOLVED; 37 } 38 39 raise(SIGCHLD); 40 41 if (handler_called != 1) { 42 printf 43 ("Test FAILED: handler was called even though default was expected\n"); 44 return PTS_FAIL; 45 } 46 return PTS_PASS; 47 } 48