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 SIGURG to use handler1 15 2. Call sigaction again to set handler for SIGURG 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 handler1(int signo LTP_ATTRIBUTE_UNUSED)24void handler1(int signo LTP_ATTRIBUTE_UNUSED) 25 { 26 } 27 handler2(int signo LTP_ATTRIBUTE_UNUSED)28void handler2(int signo LTP_ATTRIBUTE_UNUSED) 29 { 30 } 31 main(void)32int main(void) 33 { 34 struct sigaction act; 35 struct sigaction oact; 36 37 act.sa_handler = handler1; 38 act.sa_flags = 0; 39 sigemptyset(&act.sa_mask); 40 if (sigaction(SIGURG, &act, 0) == -1) { 41 perror("Unexpected error while attempting to setup test " 42 "pre-conditions"); 43 return PTS_UNRESOLVED; 44 } 45 46 act.sa_handler = handler2; 47 sigemptyset(&act.sa_mask); 48 if (sigaction(SIGURG, &act, &oact) == -1) { 49 perror("Unexpected error while attempting to setup test " 50 "pre-conditions"); 51 return PTS_UNRESOLVED; 52 } 53 54 if (oact.sa_handler == handler1) { 55 printf("Test PASSED\n"); 56 return PTS_PASS; 57 } 58 59 printf("Test Failed\n"); 60 return PTS_FAIL; 61 } 62