source: vendor/glibc-tests/2005-06-14/linuxthreads/bug-sleep.c

Last change on this file was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 550 bytes
Line 
1/* PR libc/4005 */
2#include <pthread.h>
3#include <stdio.h>
4#include <unistd.h>
5#include <time.h>
6
7void *
8run_thread (void *a)
9{
10 while (1)
11 {
12 sleep (10);
13 }
14 return 0;
15}
16
17int
18main (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}
Note: See TracBrowser for help on using the repository browser.