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 18 #include <signal.h> 19 #include <stdio.h> 20 #include <stdlib.h> 21 #include "posixtest.h" 22 23 static volatile int handler_called; 24 myhandler(int signo LTP_ATTRIBUTE_UNUSED)25void myhandler(int signo LTP_ATTRIBUTE_UNUSED) 26 { 27 printf("SIGCHLD called. Inside handler\n"); 28 handler_called = 1; 29 } 30 main(void)31int main(void) 32 { 33 if (sigset(SIGCHLD, myhandler) == SIG_ERR) { 34 perror("Unexpected error while using sigset()"); 35 return PTS_UNRESOLVED; 36 } 37 38 raise(SIGCHLD); 39 40 if (handler_called != 1) { 41 printf 42 ("Test FAILED: handler was called even though default was expected\n"); 43 return PTS_FAIL; 44 } 45 return PTS_PASS; 46 } 47