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 signal function shall return 9 the function name of the last signal handler that was associated with 10 sig. 11 12 How this program tests this assertion is by setting up handlers 13 SIGUSR1_handler and SIGUSR2_handler for signals SIGUSR1 and SIGUSR2 14 respectively. A third call to signal() is made regarding signal SIGUSR1. 15 If this call returns anything but SIGUSR1_handler, fail the test, 16 otherwise the test passes. 17 18 */ 19 20 #include <signal.h> 21 #include <stdio.h> 22 #include <stdlib.h> 23 #include "posixtest.h" 24 25 void SIGUSR1_handler(int signo) 26 { 27 printf("do nothing useful\n"); 28 } 29 30 void SIGUSR2_handler(int signo) 31 { 32 printf("do nothing useful\n"); 33 } 34 35 int main(void) 36 { 37 if (signal(SIGUSR1, SIGUSR1_handler) == SIG_ERR) { 38 perror("Unexpected error while using signal()"); 39 return PTS_UNRESOLVED; 40 } 41 42 if (signal(SIGUSR2, SIGUSR2_handler) == SIG_ERR) { 43 perror("Unexpected error while using signal()"); 44 return PTS_UNRESOLVED; 45 } 46 47 if (signal(SIGUSR1, SIG_IGN) != SIGUSR1_handler) { 48 printf 49 ("signal did not return the last handler that was associated with SIGUSR1\n"); 50 return PTS_FAIL; 51 } 52 53 return PTS_PASS; 54 } 55