]> git.ipfire.org Git - thirdparty/glibc.git/blob - linuxthreads/bug-sleep.c
Test for stack alignment.
[thirdparty/glibc.git] / linuxthreads / bug-sleep.c
1 /* PR libc/4005 */
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <time.h>
6
7 void *
8 run_thread (void *a)
9 {
10 while (1)
11 {
12 sleep (10);
13 }
14 return 0;
15 }
16
17 int
18 main (void)
19 {
20 pthread_t thr;
21 void *result;
22 alarm (4);
23 printf ("Starting thread.\n");
24 pthread_create (&thr, 0, run_thread, 0);
25 sleep (2);
26 printf ("Canceling thread.\n");
27 pthread_cancel (thr);
28 pthread_join (thr, &result);
29 if (result == PTHREAD_CANCELED)
30 printf ("Thread canceled.\n");
31 else
32 printf ("Thread exited.\n");
33 return 0;
34 }