Update.
[glibc.git] / linuxthreads / bug-sleep.c
blobf29a6b73c02ca24f6ff782a3dfccd432c94d4723
1 /* PR libc/4005 */
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <time.h>
7 void *
8 run_thread (void *a)
10 while (1)
12 sleep (10);
14 return 0;
17 int
18 main (void)
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;