1 /* $FreeBSD$ */ 2 /* Test stack unwinding for pthread_cond_wait function */ 3 4 #include <pthread.h> 5 #include <stdio.h> 6 #include <semaphore.h> 7 #include <unistd.h> 8 9 #include "Test.cpp" 10 11 pthread_mutex_t mtx; 12 pthread_cond_t cv; 13 14 void * 15 thr(void *arg) 16 { 17 Test t; 18 19 pthread_mutex_lock(&mtx); 20 pthread_cond_wait(&cv, &mtx); 21 pthread_mutex_unlock(&mtx); 22 printf("Bug, thread shouldn't be here.\n"); 23 return (0); 24 } 25 26 int 27 main() 28 { 29 pthread_t td; 30 31 pthread_mutex_init(&mtx, NULL); 32 pthread_cond_init(&cv, NULL); 33 pthread_create(&td, NULL, thr, NULL); 34 sleep(1); 35 pthread_cancel(td); 36 pthread_join(td, NULL); 37 check_destruct(); 38 return (0); 39 } 40