1 /* Copyright (C) 2006-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
22 #include <sys/select.h>
27 static volatile int handler_called
;
40 sa
.sa_handler
= handler
;
42 sigemptyset (&sa
.sa_mask
);
44 if (sigaction (SIGUSR1
, &sa
, NULL
) != 0)
46 puts ("sigaction failed");
50 sa
.sa_handler
= SIG_IGN
;
51 if (sigaction (SIGCHLD
, &sa
, NULL
) != 0)
53 puts ("2nd sigaction failed");
58 sigemptyset (&ss_usr1
);
59 sigaddset (&ss_usr1
, SIGUSR1
);
60 if (sigprocmask (SIG_BLOCK
, &ss_usr1
, NULL
) != 0)
62 puts ("sigprocmask failed");
68 if (pipe (fds
[0]) != 0 || pipe (fds
[1]) != 0)
78 sigprocmask (SIG_SETMASK
, NULL
, &ss
);
79 sigdelset (&ss
, SIGUSR1
);
81 struct timespec to
= { .tv_sec
= 0, .tv_nsec
= 500000000 };
83 pid_t parent
= getpid ();
90 FD_SET (fds
[0][0], &rfds
);
95 if (getppid () != parent
)
99 e
= pselect (fds
[0][0] + 1, &rfds
, NULL
, NULL
, &to
, &ss
);
105 puts ("child: pselect did not fail");
110 puts ("child: pselect did not set errno to EINTR");
114 TEMP_FAILURE_RETRY (write (fds
[1][1], "foo", 3));
122 FD_SET (fds
[1][0], &rfds
);
126 int e
= pselect (fds
[1][0] + 1, &rfds
, NULL
, NULL
, NULL
, &ss
);
129 puts ("parent: pselect failed");
134 puts ("parent: pselect did not report readable fd");
137 if (!FD_ISSET (fds
[1][0], &rfds
))
139 puts ("parent: pselect reports wrong fd");
146 #define TEST_FUNCTION do_test ()
147 #include "../test-skeleton.c"