1 /* $OpenBSD: process_kill.c,v 1.1 2012/03/07 22:01:29 fgsch Exp $ */
2 /*
3 * Federico G. Schwindt <fgsch@openbsd.org>, 2012. Public Domain.
4 */
5
6 #include <pthread.h>
7 #include <signal.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include "test.h"
11
12 void
deadlock(int sig)13 deadlock(int sig)
14 {
15 PANIC("deadlock detected");
16 }
17
18 void
handler(int sig)19 handler(int sig)
20 {
21
22 }
23
24 void *
killer(void * arg)25 killer(void *arg)
26 {
27 sleep(2);
28 CHECKe(kill(getpid(), SIGUSR1));
29 return (NULL);
30 }
31
32 int
main(int argc,char ** argv)33 main(int argc, char **argv)
34 {
35 pthread_t t;
36
37 ASSERT(signal(SIGALRM, deadlock) != SIG_ERR);
38 ASSERT(signal(SIGUSR1, handler) != SIG_ERR);
39 CHECKr(pthread_create(&t, NULL, killer, NULL));
40 alarm(5);
41 sleep(15);
42 CHECKr(pthread_join(t, NULL));
43 SUCCEED;
44 }
45