8 /* Make sure that a blocking syscall restarts if hit by a signal,
9 and SA_RESTART is set */
11 static void handler(int s
)
20 if (pipe(fds
) == -1) {
21 perror("FAIL: pipe\n");
28 perror("fork failed");
37 sa
.sa_handler
= handler
;
38 sigfillset(&sa
.sa_mask
);
39 sa
.sa_flags
= SA_RESTART
;
41 sigaction(SIGUSR1
, &sa
, NULL
);
44 ret
= read(fds
[0], &ch
, 1);
46 if (ret
!= 1 || ch
!= 'x')
47 fprintf(stderr
, "FAIL: expected 1 byte, not %d/%s/%c\n",
48 ret
, strerror(errno
), ch
);
50 signal(SIGPIPE
, SIG_IGN
);
56 write(fds
[1], "x", 1);
58 waitpid(pid
, NULL
, 0);