Debian Codegraph @

gcc/testsuite/gcc.target/arc/cancel-1.c

raw
1 /* Test for cleanups with pthread_cancel. Any issue with libgcc's unwinder
2 will cause this test to spin in pthread_join. */
3
4 /* { dg-do run } */
5 /* { dg-require-effective-target pthread } */
6 /* { dg-options "-pthread" } */
7
8 #include <pthread.h>
9 #include <unistd.h>
10 #include <stdio.h>
11
12 void *thread_loop (void *)
13 {
14 while (1)
15 {
16 printf("worker: loop\n");
17 sleep(1);
18 }
19 }
20
21 int main ()
22 {
23 pthread_t thread;
24
25 pthread_create (&thread, 0, thread_loop, 0);
26 sleep(5);
27 pthread_cancel (thread);
28 pthread_join (thread, 0);
29
30 return 0;
31 }