Home | History | Annotate | Download | only in pthread_sigmask
      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  Steps:
      9  1. Call pthread_sigmask with correct parameter, and check that 0 is returned.
     10 */
     11 
     12 #include <pthread.h>
     13 #include <errno.h>
     14 #include <signal.h>
     15 #include <stdio.h>
     16 #include <stdlib.h>
     17 #include "posixtest.h"
     18 
     19 void *a_thread_func()
     20 {
     21 
     22 	sigset_t actl;
     23 /*
     24 	printf("SIG_SETMASK=%d\n", SIG_SETMASK);
     25 	printf("SIG_BLOCK=%d\n", SIG_BLOCK);
     26 	printf("SIG_UNBLOCK=%d\n", SIG_UNBLOCK);
     27 	printf("r=%d\n", r);
     28 */
     29 	sigemptyset(&actl);
     30 	sigaddset(&actl, SIGABRT);
     31 
     32 	if (pthread_sigmask(SIG_SETMASK, &actl, NULL) != 0) {
     33 		perror("pthread_sigmask() did not return 0\n");
     34 		pthread_exit((void *)-1);
     35 	}
     36 
     37 	printf("PASS: pthread_sigmask returned 0.\n");
     38 	pthread_exit(NULL);
     39 
     40 	/* To please some compilers */
     41 	return NULL;
     42 }
     43 
     44 int main(void)
     45 {
     46 
     47 	int *thread_return_value;
     48 
     49 	pthread_t new_thread;
     50 
     51 	if (pthread_create(&new_thread, NULL, a_thread_func, NULL) != 0) {
     52 		perror("Error creating new thread\n");
     53 		return PTS_UNRESOLVED;
     54 	}
     55 
     56 	if (pthread_join(new_thread, (void *)&thread_return_value) != 0) {
     57 		perror("Error in pthread_join()\n");
     58 		return PTS_UNRESOLVED;
     59 	}
     60 
     61 	if ((long)thread_return_value != 0) {
     62 		if ((long)thread_return_value == 1) {
     63 			printf("Test UNRESOLVED\n");
     64 			return PTS_UNRESOLVED;
     65 		} else if ((long)thread_return_value == -1) {
     66 			printf("Test FAILED\n");
     67 			return PTS_FAIL;
     68 		} else {
     69 			printf("Test UNRESOLVED\n");
     70 			return PTS_UNRESOLVED;
     71 		}
     72 	}
     73 	return PTS_PASS;
     74 }
     75