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 Steps: 9 1. Set up a handler for signal SIGABRT, such that it is called if signal is ever raised. 10 2. Call sighold on that SIGABRT. 11 3. Raise a SIGABRT and verify that the signal handler was not called. 12 13 */ 14 15 16 #include <signal.h> 17 #include <stdio.h> 18 #include <unistd.h> 19 #include "posixtest.h" 20 21 static int handler_called = 0; 22 23 static void handler(int signo) 24 { 25 handler_called = 1; 26 } 27 28 int main(void) 29 { 30 struct sigaction act; 31 32 act.sa_handler = handler; 33 act.sa_flags = 0; 34 sigemptyset(&act.sa_mask); 35 if (sigaction(SIGABRT, &act, 0) == -1) { 36 perror("Unexpected error while attempting to setup test " 37 "pre-conditions"); 38 return PTS_UNRESOLVED; 39 } 40 41 if (sighold(SIGABRT) == -1) { 42 perror("Unexpected error while attempting to setup test " 43 "pre-conditions"); 44 return PTS_UNRESOLVED; 45 } 46 47 if (raise(SIGABRT) == -1) { 48 perror("Unexpected error while attempting to setup test " 49 "pre-conditions"); 50 return PTS_UNRESOLVED; 51 } 52 53 usleep(100000); 54 55 if (handler_called) { 56 printf("FAIL: Signal was not blocked\n"); 57 return PTS_FAIL; 58 } 59 60 printf("Test PASSED: signal was blocked\n"); 61 return PTS_PASS; 62 } 63