1 /* 2 3 * Copyright (c) 2002-2003, Intel Corporation. All rights reserved. 4 * Created by: rusty.lynch REMOVE-THIS AT intel DOT com 5 * This file is licensed under the GPL license. For the full content 6 * of this license, see the COPYING file at the top level of this 7 * source tree. 8 9 Test case for assertion #3 of the sigaction system call that shows 10 calling sigaction with a null act argument does not change the 11 signal handler. 12 13 Steps: 14 1. Initialize global variable to indicate handler has not been called 15 2. Set the signal handler for %%MYSIG%% to handler 16 3. Call sigaction with a null act 17 4. raise %%MYSIG%% 18 5. Verify handler was called. 19 */ 20 21 #include <signal.h> 22 #include <stdio.h> 23 #include "posixtest.h" 24 25 int handler_called = 0; 26 27 void handler(int signo) 28 { 29 handler_called = 1; 30 } 31 32 int main() 33 { 34 struct sigaction act; 35 struct sigaction oact; 36 37 act.sa_handler = handler; 38 act.sa_flags = 0; 39 sigemptyset(&act.sa_mask); 40 if (sigaction(%%MYSIG%%, &act, 0) == -1) { 41 perror("Unexpected error while attempting to setup test " 42 "pre-conditions"); 43 return PTS_UNRESOLVED; 44 } 45 46 if (sigaction(%%MYSIG%%, 0, &oact) == -1) { 47 perror("Unexpected error while attempting to setup test " 48 "pre-conditions"); 49 return PTS_UNRESOLVED; 50 } 51 52 53 if (raise(%%MYSIG%%) == -1) { 54 perror("Unexpected error while attempting to setup test " 55 "pre-conditions"); 56 return PTS_UNRESOLVED; 57 } 58 59 if (handler_called) { 60 printf("Test PASSED\n"); 61 return PTS_PASS; 62 } 63 64 printf("Test FAILED\n"); 65 return PTS_FAIL; 66 } 67 68