Home | History | Annotate | Download | only in sigaction
      1 /*
      2  * Copyright (c) 2002-2003, Intel Corporation. All rights reserved.
      3  * Created by:  rusty.lynch 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   Test case for assertion #5 of the sigaction system call that verifies
      9   setting the SA_INFO bit in the signal mask for SIGTTIN will result
     10   in sa_sigaction identifying the signal-catching function.
     11 */
     12 
     13 
     14 #include <signal.h>
     15 #include <stdio.h>
     16 #include <stdlib.h>
     17 #include <sys/wait.h>
     18 #include <unistd.h>
     19 #include "posixtest.h"
     20 
     21 int handler_called = 0;
     22 
     23 void handler(int signo, siginfo_t * info, void *context)
     24 {
     25 	handler_called = 1;
     26 }
     27 
     28 int main(void)
     29 {
     30 	struct sigaction act;
     31 
     32 	act.sa_sigaction = handler;
     33 	act.sa_flags = SA_SIGINFO;
     34 	sigemptyset(&act.sa_mask);
     35 	sigaddset(&act.sa_mask, SIGSTOP);
     36 	if (sigaction(SIGTTIN, &act, 0) == -1) {
     37 		printf("Unexpected error while attempting to setup test "
     38 		       "pre-conditions\n");
     39 		return PTS_UNRESOLVED;
     40 	}
     41 
     42 	if (raise(SIGTTIN) == -1) {
     43 		printf("Unexpected error while attempting to setup test "
     44 		       "pre-conditions\n");
     45 		return PTS_UNRESOLVED;
     46 	}
     47 
     48 	if (handler_called) {
     49 		printf("Test PASSED\n");
     50 		return PTS_PASS;
     51 	}
     52 
     53 	printf("Test FAILED\n");
     54 	return PTS_FAIL;
     55 }
     56