mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Update.
* bug-sleep.c: New file. * Makefile (tests): Add bug-sleep.
This commit is contained in:
34
linuxthreads/bug-sleep.c
Normal file
34
linuxthreads/bug-sleep.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* PR libc/4005 */
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
void *
|
||||
run_thread (void *a)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
sleep (10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
pthread_t thr;
|
||||
void *result;
|
||||
alarm (4);
|
||||
printf ("Starting thread.\n");
|
||||
pthread_create (&thr, 0, run_thread, 0);
|
||||
sleep (2);
|
||||
printf ("Canceling thread.\n");
|
||||
pthread_cancel (thr);
|
||||
pthread_join (thr, &result);
|
||||
if (result == PTHREAD_CANCELED)
|
||||
printf ("Thread canceled.\n");
|
||||
else
|
||||
printf ("Thread exited.\n");
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user