2010-09-25 00:26:40 -04:00
|
|
|
/* $FreeBSD$ */
|
|
|
|
|
/* try to catch thread exiting, and rethrow the exception */
|
|
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2022-02-16 16:10:45 -05:00
|
|
|
static int caught;
|
2010-09-25 00:26:40 -04:00
|
|
|
|
2022-02-16 16:10:45 -05:00
|
|
|
static void *
|
|
|
|
|
thr_routine(void *arg __unused)
|
2010-09-25 00:26:40 -04:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|