1285SN/A/* $FreeBSD$ */
2462SN/A/* Test stack unwinding for libc's sem */
3285SN/A
4285SN/A#include <pthread.h>
5285SN/A#include <stdio.h>
6285SN/A#include <semaphore.h>
7285SN/A#include <unistd.h>
8285SN/A
9285SN/A#include "Test.cpp"
10285SN/A
11285SN/Asem_t sem;
12285SN/A
13285SN/Avoid *
14285SN/Athr(void *arg)
15285SN/A{
16285SN/A	Test t;
17285SN/A
18285SN/A	sem_wait(&sem);
19285SN/A	printf("Bug, thread shouldn't be here.\n");
20285SN/A	return (0);
21285SN/A}
22285SN/A
23285SN/Aint
24285SN/Amain()
25285SN/A{
26285SN/A	pthread_t td;
27285SN/A
28285SN/A	sem_init(&sem, 0, 0);
29285SN/A	pthread_create(&td, NULL, thr, NULL);
30285SN/A	sleep(1);
31285SN/A	pthread_cancel(td);
32396SN/A	pthread_join(td, NULL);
33396SN/A	check_destruct();
34396SN/A	return (0);
35396SN/A}
36396SN/A