1 // commit: 370f78f2c80c64b7b0780a01e672494a26b5678e 2011-03-09
2 // commit: 0bed7e0acfd34e3fb63ca0e4d99b7592571355a9 2011-03-09
3 // raise should be robust against async fork in a signal handler
12 static volatile int c0;
13 static volatile int c1;
14 static volatile int child;
16 static void handler0(int sig)
21 static void handler1(int sig)
25 case 0: child=1; break;
26 case -1: t_error("fork failed: %s\n", strerror(errno));
30 static void *start(void *arg)
34 for (i = 0; i < 1000; i++) {
37 t_error("raise failed: %s\n", strerror(errno));
40 t_error("lost signals: got %d, wanted 1000 (ischild %d forks %d)\n", c0, child, c1);
44 /* make sure we got all pthread_kills, then wait the forked children */
46 for (i = 0; i < 100; i++) {
49 t_error("wait failed: %s\n", strerror(errno));
50 else if (!WIFEXITED(s) || WTERMSIG(s))
51 t_error("child failed: pid:%d status:%d\n", r, s);
62 if (signal(SIGRTMIN, handler0) == SIG_ERR)
63 t_error("registering signal handler failed: %s\n", strerror(errno));
64 if (signal(SIGRTMIN+1, handler1) == SIG_ERR)
65 t_error("registering signal handler failed: %s\n", strerror(errno));
67 r = pthread_create(&t, 0, start, 0);
69 t_error("pthread_create failed: %s\n", strerror(r));
70 for (i = 0; i < 100; i++) {
71 r = pthread_kill(t, SIGRTMIN+1);
73 t_error("phread_kill failed: %s\n", strerror(r));
75 r = pthread_join(t,&p);
77 t_error("pthread_join failed: %s\n", strerror(r));