1 /* 2 Test the error condition of calling sigdelset() twice for the same 3 signo. 4 Test steps: 5 1) Initialize an empty signal set. 6 2) Add the SIGALRM signal to the empty signal set and verify. 7 3) Remove the SIGALRM signal from the signal set and verify removed. 8 4) Attempt to remove again and verify signal is still removed. 9 */ 10 #include <stdio.h> 11 #include <signal.h> 12 #include "posixtest.h" 13 main(void)14int main(void) 15 { 16 sigset_t signalset; 17 18 if (sigemptyset(&signalset) == -1) { 19 perror("sigemptyset failed -- test aborted"); 20 return PTS_UNRESOLVED; 21 } 22 if (sigaddset(&signalset, SIGALRM) == 0) { 23 if (sigismember(&signalset, SIGALRM) == 0) { 24 printf("sigaddset returned, sigismember failed\n"); 25 return PTS_UNRESOLVED; 26 } 27 } else { 28 printf("sigaddset did not successfully add signal\n"); 29 return PTS_UNRESOLVED; 30 } 31 32 if (sigdelset(&signalset, SIGALRM) == 0) { 33 if (sigismember(&signalset, SIGALRM) == 1) { 34 printf("Signal is still in signal set.\n"); 35 return PTS_FAIL; 36 } 37 } else { 38 printf("sigdelset() failed\n"); 39 return PTS_FAIL; 40 } 41 42 sigdelset(&signalset, SIGALRM); 43 if (sigismember(&signalset, SIGALRM) == 0) { 44 printf("Test PASSED\n"); 45 return PTS_PASS; 46 } else { 47 printf("Test FAILED\n"); 48 return PTS_FAIL; 49 } 50 } 51