1 // commit: 370f78f2c80c64b7b0780a01e672494a26b5678e 2011-03-09
2 // raise should be robust against forking from a signal handler
11 static volatile int c0;
12 static volatile int c1;
13 static volatile int child;
15 static void handler0(int sig)
20 static void handler1(int sig)
24 case 0: child=1; break;
25 case -1: t_error("fork failed: %s\n", strerror(errno));
29 static void *start(void *arg)
33 for (i = 0; i < 1000; i++) {
36 t_error("raise failed: %s\n", strerror(errno));
39 t_error("lost signals: got %d, wanted 1000 (ischild %d forks %d)\n", c0, child, c1);
43 /* make sure we got all pthread_kills, then wait the forked children */
45 for (i = 0; i < 100; i++) {
48 t_error("wait failed: %s\n", strerror(errno));
49 else if (!WIFEXITED(s) || WTERMSIG(s))
50 t_error("child failed: pid:%d status:%d\n", r, s);
61 signal(SIGRTMIN, handler0);
62 signal(SIGRTMIN+1, handler1);
64 pthread_create(&t, 0, start, 0);
65 for (i = 0; i < 100; i++)
66 pthread_kill(t, SIGRTMIN+1);