(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / Examples / ex15.c
blobe953b231d739047899680ed5dbe8f1728f92a611
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 *worker (void *dummy) __attribute__ ((__noreturn__));
10 static void *
11 worker (void *dummy)
13 exit (26);
16 #define TEST_FUNCTION do_test ()
17 #define TIMEOUT 10
18 static int
19 do_test (void)
21 pthread_t th;
22 pid_t pid;
23 int status;
25 switch ((pid = fork ()))
27 case -1:
28 puts ("Could not fork");
29 exit (1);
30 case 0:
31 if (pthread_create(&th, NULL, worker, NULL) != 0)
33 puts ("Failed to start thread");
34 exit (1);
36 for (;;);
37 exit (1);
38 default:
39 break;
42 if (waitpid (pid, &status, 0) != pid)
44 puts ("waitpid failed");
45 exit (1);
48 if (!WIFEXITED (status) || WEXITSTATUS (status) != 26)
50 printf ("Wrong exit code %d\n", status);
51 exit (1);
54 puts ("All OK");
55 return 0;
58 #include "../../test-skeleton.c"