1 // Test for "sticky cancel": if a catch (...) block discards the
2 // cancellation exception, a new one is raised at the next cancellation
5 // This test only applies to glibc targets.
6 // { dg-do run { target *-*-linux* } }
7 // { dg-options "-pthread" }
11 extern "C" int printf (const char *, ...);
13 void* thread_main(void*)
17 // Spin until we get cancelled.
23 // Catch and discard the forced unwind.
24 printf ("caught ...\n");
29 // Start unwinding again.
34 // Catch and discard again. This time the thread exits before the
35 // next cancellation point, so we're done.
36 printf ("caught ... again\n");
49 r = pthread_create (&thread, NULL, thread_main, NULL);
53 r = pthread_cancel (thread);
57 r = pthread_join (thread, &p);