Bug 385411 s390x: Tests and internals for z13 vector FP support
[valgrind.git] / none / tests / threaded-fork.c
blobde5228c5caa15c0f76047e153da5a89a39bc6bc3
1 #include <stdlib.h>
2 #include <sys/wait.h>
3 #include <pthread.h>
4 #include <sys/types.h>
5 #include <unistd.h>
6 #include <stdio.h>
7 #include <signal.h>
9 static void *threadmain( void *dummy )
11 sleep( (unsigned long)dummy );
12 return NULL;
15 int main( int argc, char **argv )
17 int ctr;
18 pid_t childpid;
19 pthread_t childthread;
20 void *res;
21 int status;
23 pthread_create( &childthread, NULL, threadmain, (void *)2 );
25 childpid = fork();
26 switch( childpid ) {
27 case 0:
28 pthread_create( &childthread, NULL, threadmain, 0 );
29 pthread_join( childthread, &res );
30 exit(0);
31 break;
32 case -1:
33 perror( "FAILED: fork failed\n" );
34 break;
35 default:
36 break;
39 pthread_join( childthread, &res );
40 ctr = 0;
41 while(waitpid(childpid, &status, 0) != childpid) {
42 sleep(1);
43 ctr++;
44 if (ctr >= 10) {
45 printf("FAILED - timeout waiting for child\n");
46 return 0;
50 printf("PASS\n");
52 return 0;