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 #13 of the sigaction system call that verifies 10 signal-catching functions are executed on the current stack if the 11 SA_ONSTACK flag is cleared in the sigaction.sa_flags parameter to the 12 sigaction function call. 13 14 NOTE: This test case does not attempt to verify the proper operation 15 of sigaltstack. 16 */ 17 18 #define _XOPEN_SOURCE 600 19 20 #include <signal.h> 21 #include <stdio.h> 22 #include <stdlib.h> 23 #include "posixtest.h" 24 25 stack_t current; 26 handler(int signo)27void handler(int signo) 28 { 29 stack_t oss; 30 31 printf("Caught SIGTTIN\n"); 32 33 if (sigaltstack(NULL, &oss) == -1) { 34 perror("Unexpected error while attempting to setup test " 35 "pre-conditions"); 36 exit(-1); 37 } 38 39 if (oss.ss_sp != current.ss_sp || oss.ss_size != current.ss_size) { 40 printf("Test FAILED\n"); 41 exit(-1); 42 } 43 } 44 main(void)45int main(void) 46 { 47 struct sigaction act; 48 49 act.sa_handler = handler; 50 act.sa_flags = 0; 51 sigemptyset(&act.sa_mask); 52 if (sigaction(SIGTTIN, &act, 0) == -1) { 53 perror("Unexpected error while attempting to setup test " 54 "pre-conditions"); 55 return PTS_UNRESOLVED; 56 } 57 58 if (sigaltstack(NULL, ¤t) == -1) { 59 perror("Unexpected error while attempting to setup test " 60 "pre-conditions"); 61 return PTS_UNRESOLVED; 62 } 63 64 if (raise(SIGTTIN) == -1) { 65 perror("Unexpected error while attempting to setup test " 66 "pre-conditions"); 67 return PTS_UNRESOLVED; 68 } 69 70 printf("Test PASSED\n"); 71 return PTS_PASS; 72 } 73