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 #8 of the sigaction system call that verifies
      9   that if signals in the sa_mask (passed in the sigaction struct of the
     10   sigaction function call) are added to the process signal mask during
     11   execution of the signal-catching function.
     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 SIGXFSZ_count = 0;
     22 
     23 void SIGXFSZ_handler(int signo)
     24 {
     25 	SIGXFSZ_count++;
     26 	printf("Caught SIGXFSZ\n");
     27 }
     28 
     29 void SIGABRT_handler(int signo)
     30 {
     31 	printf("Caught SIGABRT\n");
     32 	raise(SIGXFSZ);
     33 	if (SIGXFSZ_count) {
     34 		printf("Test FAILED\n");
     35 		exit(-1);
     36 	}
     37 }
     38 
     39 int main(void)
     40 {
     41 	struct sigaction act;
     42 
     43 	act.sa_handler = SIGABRT_handler;
     44 	act.sa_flags = 0;
     45 	sigemptyset(&act.sa_mask);
     46 	sigaddset(&act.sa_mask, SIGXFSZ);
     47 	if (sigaction(SIGABRT, &act, 0) == -1) {
     48 		perror("Unexpected error while attempting to "
     49 		       "setup test pre-conditions");
     50 		return PTS_UNRESOLVED;
     51 	}
     52 
     53 	act.sa_handler = SIGXFSZ_handler;
     54 	act.sa_flags = 0;
     55 	sigemptyset(&act.sa_mask);
     56 	if (sigaction(SIGXFSZ, &act, 0) == -1) {
     57 		perror("Unexpected error while attempting to "
     58 		       "setup test pre-conditions");
     59 		return PTS_UNRESOLVED;
     60 	}
     61 
     62 	if (raise(SIGABRT) == -1) {
     63 		perror("Unexpected error while attempting to "
     64 		       "setup test pre-conditions");
     65 		return PTS_UNRESOLVED;
     66 	}
     67 
     68 	printf("Test PASSED\n");
     69 	return PTS_PASS;
     70 }
     71