]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/pthread/unwind/sem_wait_cancel.cpp
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / pthread / unwind / sem_wait_cancel.cpp
1 /* $FreeBSD$ */
2 /* Test stack unwinding for libc's sem */
3
4 #include <pthread.h>
5 #include <stdio.h>
6 #include <semaphore.h>
7 #include <unistd.h>
8
9 #include "Test.cpp"
10
11 sem_t sem;
12
13 void *
14 thr(void *arg)
15 {
16         Test t;
17
18         sem_wait(&sem);
19         printf("Bug, thread shouldn't be here.\n");
20         return (0);
21 }
22
23 int
24 main()
25 {
26         pthread_t td;
27
28         sem_init(&sem, 0, 0);
29         pthread_create(&td, NULL, thr, NULL);
30         sleep(1);
31         pthread_cancel(td);
32         pthread_join(td, NULL);
33         check_destruct();
34         return (0);
35 }