1 /* $NetBSD: conddestroy1.c,v 1.1 2004/07/07 21:53:10 nathanw Exp $ */
4 * XXX This test is bogus. IEEE Std 1003.1, 2004 Edition says:
6 * If a signal is delivered to a thread waiting for a condition
7 * variable, upon return from the signal handler the thread resumes
8 * waiting for the condition variable as if it was not interrupted,
9 * or it shall return zero due to spurious wakeup.
18 void *threadroutine(void *);
31 threadroutine(void *arg
)
36 sigaddset(&set
, SIGALRM
);
38 pthread_sigmask(SIG_UNBLOCK
, &set
, NULL
);
40 pthread_mutex_lock(&mt
);
43 * Explicitly not a loop; we want to see if the cv is properly
44 * torn down in a spurious wakeup (generated here by SIGALRM).
46 pthread_cond_wait(&cv
, &mt
);
48 pthread_mutex_unlock(&mt
);
60 printf("Testing CV teardown under spurious wakeups.\n");
64 pthread_sigmask(SIG_BLOCK
, &set
, NULL
);
66 act
.sa_handler
= handler
;
67 sigemptyset(&act
.sa_mask
);
70 sigaction(SIGALRM
, &act
, NULL
);
72 pthread_mutex_init(&mt
, NULL
);
73 pthread_cond_init(&cv
, NULL
);
75 pthread_create(&th
, NULL
, threadroutine
, NULL
);
79 pthread_join(th
, NULL
);
81 pthread_cond_destroy(&cv
);
82 pthread_mutex_destroy(&mt
);