5 #include <sys/select.h>
9 static volatile int handler_called
;
22 sa
.sa_handler
= handler
;
24 sigemptyset (&sa
.sa_mask
);
26 if (sigaction (SIGUSR1
, &sa
, NULL
) != 0)
28 puts ("sigaction failed");
32 sa
.sa_handler
= SIG_IGN
;
33 sa
.sa_flags
= SA_NOCLDWAIT
;
35 if (sigaction (SIGCHLD
, &sa
, NULL
) != 0)
37 puts ("2nd sigaction failed");
41 if (sigblock (SIGUSR1
) != 0)
43 puts ("sigblock failed");
49 if (pipe (fds
[0]) != 0 || pipe (fds
[1]) != 0)
59 sigprocmask (SIG_SETMASK
, NULL
, &ss
);
60 sigdelset (&ss
, SIGUSR1
);
62 struct timespec to
= { .tv_sec
= 0, .tv_nsec
= 500000000 };
64 pid_t parent
= getpid ();
71 FD_SET (fds
[0][0], &rfds
);
76 if (getppid () != parent
)
80 e
= pselect (fds
[0][0] + 1, &rfds
, NULL
, NULL
, &to
, &ss
);
86 puts ("child: pselect did not fail");
91 puts ("child: pselect did not set errno to EINTR");
95 TEMP_FAILURE_RETRY (write (fds
[1][1], "foo", 3));
103 FD_SET (fds
[1][0], &rfds
);
107 int e
= pselect (fds
[1][0] + 1, &rfds
, NULL
, NULL
, NULL
, &ss
);
110 puts ("parent: pselect failed");
115 puts ("parent: pselect did not report readable fd");
118 if (!FD_ISSET (fds
[1][0], &rfds
))
120 puts ("parent: pselect reports wrong fd");
127 #define TEST_FUNCTION do_test ()
128 #include "../test-skeleton.c"