(res_isourserver): Fix cast.
[glibc/pb-stable.git] / linuxthreads / Examples / ex15.c
blobf73b940949f2b3bb6d2b13ea3adbd871500c5421
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/types.h>
4 #include <sys/wait.h>
5 #include <pthread.h>
6 #include <unistd.h>
8 static void *
9 worker (void *dummy)
11 exit (26);
14 #define TEST_FUNCTION do_test ()
15 #define TIMEOUT 10
16 static int
17 do_test (void)
19 pthread_t th;
20 pid_t pid;
21 int status;
23 switch ((pid = fork ()))
25 case -1:
26 puts ("Could not fork");
27 exit (1);
28 case 0:
29 if (pthread_create(&th, NULL, worker, NULL) != 0)
31 puts ("Failed to start thread");
32 exit (1);
34 for (;;);
35 exit (1);
36 default:
37 break;
40 if (waitpid (pid, &status, 0) != pid)
42 puts ("waitpid failed");
43 exit (1);
46 if (!WIFEXITED (status) || WEXITSTATUS (status) != 26)
48 printf ("Wrong exit code %d\n", status);
49 exit (1);
52 puts ("All OK");
53 return 0;
56 #include "../../test-skeleton.c"