Expand PMF_FN_* macros.
[netbsd-mini2440.git] / regress / lib / libpthread / siglongjmp1 / siglongjmp1.c
bloba1989f60f430dc50673ff6652a23d10022cb83c5
1 /* $NetBSD:$ */
3 /*
4 * Regression test for siglongjmp out of a signal handler back into
5 * its thread.
7 * Written by Christian Limpach <cl@NetBSD.org>, December 2003.
8 * Public domain.
9 */
11 #include <err.h>
12 #include <pthread.h>
13 #include <setjmp.h>
14 #include <signal.h>
15 #include <unistd.h>
17 #include <sys/resource.h>
19 void *thread(void *);
20 void handler(int, siginfo_t *, void *);
21 static sigjmp_buf env;
23 void *
24 thread(void *arg)
26 return NULL;
29 void
30 handler(int sig, siginfo_t *info, void *ctx)
32 siglongjmp(env, 1);
35 int
36 main(int argc, char **argv)
38 pthread_t t;
39 sigset_t nset;
40 struct rlimit rlim;
41 struct sigaction act;
43 rlim.rlim_cur = rlim.rlim_max = 0;
44 (void)setrlimit(RLIMIT_CORE, &rlim);
46 pthread_create(&t, NULL, thread, NULL);
48 sigemptyset(&nset);
49 sigaddset(&nset, SIGUSR1);
50 pthread_sigmask(SIG_SETMASK, &nset, NULL);
52 act.sa_sigaction = handler;
53 sigemptyset(&act.sa_mask);
54 sigaddset(&act.sa_mask, SIGUSR2);
55 act.sa_flags = 0;
56 sigaction(SIGSEGV, &act, NULL);
58 if (sigsetjmp(env, 1) == 0)
59 *(long *)0 = 0;
61 pthread_sigmask(0, NULL, &nset);
63 if (sigismember(&nset, SIGSEGV))
64 errx(1, "SIGSEGV set");
65 if (sigismember(&nset, SIGUSR2))
66 errx(1, "SIGUSR2 set");
67 if (!sigismember(&nset, SIGUSR1))
68 errx(1, "SIGUSR1 not set");
70 return 0;