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 if (sigaction (SIGCHLD
, &sa
, NULL
) != 0)
36 puts ("2nd sigaction failed");
41 sigemptyset (&ss_usr1
);
42 sigaddset (&ss_usr1
, SIGUSR1
);
43 if (sigprocmask (SIG_BLOCK
, &ss_usr1
, NULL
) != 0)
45 puts ("sigprocmask failed");
51 if (pipe (fds
[0]) != 0 || pipe (fds
[1]) != 0)
61 sigprocmask (SIG_SETMASK
, NULL
, &ss
);
62 sigdelset (&ss
, SIGUSR1
);
64 struct timespec to
= { .tv_sec
= 0, .tv_nsec
= 500000000 };
66 pid_t parent
= getpid ();
73 FD_SET (fds
[0][0], &rfds
);
78 if (getppid () != parent
)
82 e
= pselect (fds
[0][0] + 1, &rfds
, NULL
, NULL
, &to
, &ss
);
88 puts ("child: pselect did not fail");
93 puts ("child: pselect did not set errno to EINTR");
97 TEMP_FAILURE_RETRY (write (fds
[1][1], "foo", 3));
105 FD_SET (fds
[1][0], &rfds
);
109 int e
= pselect (fds
[1][0] + 1, &rfds
, NULL
, NULL
, NULL
, &ss
);
112 puts ("parent: pselect failed");
117 puts ("parent: pselect did not report readable fd");
120 if (!FD_ISSET (fds
[1][0], &rfds
))
122 puts ("parent: pselect reports wrong fd");
129 #define TEST_FUNCTION do_test ()
130 #include "../test-skeleton.c"