2010-09-25 00:26:40 -04:00
|
|
|
/* $FreeBSD$ */
|
|
|
|
|
/* Test stack unwinding for libc's sem */
|
|
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <semaphore.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "Test.cpp"
|
|
|
|
|
|
2022-02-16 16:10:45 -05:00
|
|
|
static sem_t sem;
|
2010-09-25 00:26:40 -04:00
|
|
|
|
2022-02-16 16:10:45 -05:00
|
|
|
static void *
|
|
|
|
|
thr(void *arg __unused)
|
2010-09-25 00:26:40 -04:00
|
|
|
{
|
|
|
|
|
Test t;
|
|
|
|
|
|
|
|
|
|
sem_wait(&sem);
|
|
|
|
|
printf("Bug, thread shouldn't be here.\n");
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main()
|
|
|
|
|
{
|
|
|
|
|
pthread_t td;
|
|
|
|
|
|
|
|
|
|
sem_init(&sem, 0, 0);
|
|
|
|
|
pthread_create(&td, NULL, thr, NULL);
|
|
|
|
|
sleep(1);
|
|
|
|
|
pthread_cancel(td);
|
|
|
|
|
pthread_join(td, NULL);
|
|
|
|
|
check_destruct();
|
|
|
|
|
return (0);
|
|
|
|
|
}
|