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");
43 sigemptyset (&ss_usr1
);
44 sigaddset (&ss_usr1
, SIGUSR1
);
45 if (sigprocmask (SIG_BLOCK
, &ss_usr1
, NULL
) != 0)
47 puts ("sigprocmask failed");
53 if (pipe (fds
[0]) != 0 || pipe (fds
[1]) != 0)
63 sigprocmask (SIG_SETMASK
, NULL
, &ss
);
64 sigdelset (&ss
, SIGUSR1
);
66 struct timespec to
= { .tv_sec
= 0, .tv_nsec
= 500000000 };
68 pid_t parent
= getpid ();
75 FD_SET (fds
[0][0], &rfds
);
80 if (getppid () != parent
)
84 e
= pselect (fds
[0][0] + 1, &rfds
, NULL
, NULL
, &to
, &ss
);
90 puts ("child: pselect did not fail");
95 puts ("child: pselect did not set errno to EINTR");
99 TEMP_FAILURE_RETRY (write (fds
[1][1], "foo", 3));
107 FD_SET (fds
[1][0], &rfds
);
111 int e
= pselect (fds
[1][0] + 1, &rfds
, NULL
, NULL
, NULL
, &ss
);
114 puts ("parent: pselect failed");
119 puts ("parent: pselect did not report readable fd");
122 if (!FD_ISSET (fds
[1][0], &rfds
))
124 puts ("parent: pselect reports wrong fd");
131 #define TEST_FUNCTION do_test ()
132 #include "../test-skeleton.c"