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