1/* $FreeBSD$ */ 2/* try to catch thread exiting, and rethrow the exception */ 3 4#include <pthread.h> 5#include <stdio.h> 6#include <stdlib.h> 7 8int caught; 9 10void * 11thr_routine(void *arg) 12{ 13 try { 14 pthread_exit(NULL); 15 } catch (...) { 16 caught = 1; 17 printf("thread exiting exception caught\n"); 18 /* rethrow */ 19 throw; 20 } 21} 22 23int 24main() 25{ 26 pthread_t td; 27 28 pthread_create(&td, NULL, thr_routine, NULL); 29 pthread_join(td, NULL); 30 if (caught) 31 printf("OK\n"); 32 else 33 printf("failure\n"); 34 return (0); 35} 36