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 Assumption: The test assumes that this program is run under normal conditions, 9 and not when the processor and other resources are too stressed. 10 11 This program checks to see that sigsuspend does not return when sent a signal 12 whose action is to terminate the process. 13 14 Steps: 15 1. Fork() a child. 16 2. Have the parent give the child a 1 second headstart. Have the child suspend itself. 17 3. Have the parent send the child a SIGABRT signal. The default action associated with SIGABRT 18 is to terminate the program. sigsuspend() should not return, and if it does, then have the 19 child return a to the parent with 1 or 2. 20 4. From the parent, verify that the child neither returns 1 or 2. 21 22 */ 23 24 #include <signal.h> 25 #include <sys/types.h> 26 #include <sys/wait.h> 27 #include <stdio.h> 28 #include <stdlib.h> 29 #include <unistd.h> 30 #include "posixtest.h" 31 main(void)32int main(void) 33 { 34 pid_t pid; 35 pid = fork(); 36 37 if (pid == 0) { 38 /* child */ 39 40 sigset_t tempmask; 41 42 sigemptyset(&tempmask); 43 44 printf("suspending child\n"); 45 if (sigsuspend(&tempmask) != -1) { 46 perror("sigsuspend error"); 47 return 1; 48 } 49 50 printf 51 ("Test FAILED: Should not have returned from sigsuspend\n"); 52 return 2; 53 54 } else { 55 int s; 56 int exit_status; 57 58 /* parent */ 59 sleep(1); 60 61 printf("parent sending child a SIGABRT signal\n"); 62 kill(pid, SIGABRT); 63 64 if (wait(&s) == -1) { 65 perror("Unexpected error while setting up test " 66 "pre-conditions"); 67 return PTS_UNRESOLVED; 68 } 69 70 exit_status = WEXITSTATUS(s); 71 72 printf("Exit status from child is %d\n", exit_status); 73 74 if (exit_status == 1) { 75 printf 76 ("Test UNRESOLVED: sigsuspend in child process was not successful\n"); 77 return PTS_UNRESOLVED; 78 } 79 80 if (exit_status == 2) { 81 printf 82 ("Test FAILED: sigsuspend did not suspend the child\n"); 83 return PTS_FAIL; 84 } 85 86 printf("Test PASSED\n"); 87 return PTS_PASS; 88 } 89 } 90