summaryrefslogtreecommitdiffstats
path: root/tools/regression/pthread/unwind/catch_pthread_exit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/regression/pthread/unwind/catch_pthread_exit.cpp')
-rw-r--r--tools/regression/pthread/unwind/catch_pthread_exit.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/regression/pthread/unwind/catch_pthread_exit.cpp b/tools/regression/pthread/unwind/catch_pthread_exit.cpp
new file mode 100644
index 0000000..15abc20
--- /dev/null
+++ b/tools/regression/pthread/unwind/catch_pthread_exit.cpp
@@ -0,0 +1,35 @@
+/* $FreeBSD$ */
+/* try to catch thread exiting, and rethrow the exception */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int caught;
+
+void *
+thr_routine(void *arg)
+{
+ try {
+ pthread_exit(NULL);
+ } catch (...) {
+ caught = 1;
+ printf("thread exiting exception caught\n");
+ /* rethrow */
+ throw;
+ }
+}
+
+int
+main()
+{
+ pthread_t td;
+
+ pthread_create(&td, NULL, thr_routine, NULL);
+ pthread_join(td, NULL);
+ if (caught)
+ printf("OK\n");
+ else
+ printf("failure\n");
+ return (0);
+}
OpenPOWER on IntegriCloud