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 #2 of the sigaction system call that shows 10 sigaction (when used with a non-null oact pointer) changes the action 11 for a signal. 12 13 Steps: 14 1. Call sigaction to set handler for SIGINT to use handler1 15 2. Call sigaction again to set handler for SIGINT to use handler2, 16 but this time use a non-null oarg and verify the sa_handler for 17 oarg is set for handler1. 18 */ 19 20 #include <signal.h> 21 #include <stdio.h> 22 #include "posixtest.h" 23 24 int handler_called = 0; 25 handler1(int signo)26void handler1(int signo) 27 { 28 } 29 handler2(int signo)30void handler2(int signo) 31 { 32 } 33 main(void)34int main(void) 35 { 36 struct sigaction act; 37 struct sigaction oact; 38 39 act.sa_handler = handler1; 40 act.sa_flags = 0; 41 sigemptyset(&act.sa_mask); 42 if (sigaction(SIGINT, &act, 0) == -1) { 43 perror("Unexpected error while attempting to setup test " 44 "pre-conditions"); 45 return PTS_UNRESOLVED; 46 } 47 48 act.sa_handler = handler2; 49 sigemptyset(&act.sa_mask); 50 if (sigaction(SIGINT, &act, &oact) == -1) { 51 perror("Unexpected error while attempting to setup test " 52 "pre-conditions"); 53 return PTS_UNRESOLVED; 54 } 55 56 if (oact.sa_handler == handler1) { 57 printf("Test PASSED\n"); 58 return PTS_PASS; 59 } 60 61 printf("Test Failed\n"); 62 return PTS_FAIL; 63 } 64