5 #include <sys/select.h>
10 static volatile int handler_called
;
23 sa
.sa_handler
= handler
;
25 sigemptyset (&sa
.sa_mask
);
27 if (sigaction (SIGUSR1
, &sa
, NULL
) != 0)
29 puts ("sigaction failed");
33 sa
.sa_handler
= SIG_IGN
;
34 sa
.sa_flags
= SA_NOCLDWAIT
;
36 if (sigaction (SIGCHLD
, &sa
, NULL
) != 0)
38 puts ("2nd sigaction failed");
42 if (sigblock (sigmask (SIGUSR1
)) != 0)
44 puts ("sigblock failed");
50 if (pipe (fds
[0]) != 0 || pipe (fds
[1]) != 0)
60 sigprocmask (SIG_SETMASK
, NULL
, &ss
);
61 sigdelset (&ss
, SIGUSR1
);
63 struct timespec to
= { .tv_sec
= 0, .tv_nsec
= 500000000 };
65 pid_t parent
= getpid ();
72 FD_SET (fds
[0][0], &rfds
);
77 if (getppid () != parent
)
81 e
= pselect (fds
[0][0] + 1, &rfds
, NULL
, NULL
, &to
, &ss
);
87 puts ("child: pselect did not fail");
92 puts ("child: pselect did not set errno to EINTR");
96 TEMP_FAILURE_RETRY (write (fds
[1][1], "foo", 3));
104 FD_SET (fds
[1][0], &rfds
);
108 int e
= pselect (fds
[1][0] + 1, &rfds
, NULL
, NULL
, NULL
, &ss
);
111 puts ("parent: pselect failed");
116 puts ("parent: pselect did not report readable fd");
119 if (!FD_ISSET (fds
[1][0], &rfds
))
121 puts ("parent: pselect reports wrong fd");
128 #define TEST_FUNCTION do_test ()
129 #include "../test-skeleton.c"