12 * The bug we test for: under strace -f, last two lines are swapped
13 * because wait syscall is suspended by strace and thus can't be interrupted.
16 static const char msg1[] = "Child signals parent\n";
17 static const char msg2[] = "Parent got signal\n";
18 static const char msg3[] = "Child will exit now\n";
20 static void handler(int s)
22 write(1, msg2, sizeof(msg2)-1);
27 /* Note: in Linux, signal() installs handler with SA_RESTART flag,
28 * therefore wait will be restarted.
30 signal(SIGALRM, handler);
35 write(1, msg1, sizeof(msg1)-1);
36 kill(getppid(), SIGALRM);
38 write(1, msg3, sizeof(msg3)-1);
54 printf("Please run me under 'strace -f'\n");
70 fgets(buf1, 80, stdin); printf("%s", buf1);
71 fgets(buf2, 80, stdin); printf("%s", buf2);
72 fgets(buf3, 80, stdin); printf("%s", buf3);
74 if (strcmp(buf1, msg1) != 0
75 || strcmp(buf2, msg2) != 0
76 || strcmp(buf3, msg3) != 0
78 printf("ERROR! Expected order:\n%s%s%s", msg1, msg2, msg3);
81 printf("Good: wait seems to be correctly interrupted by signals\n");