1 /* Check that sigwait does not fail with EINTR (bug 22478).
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
22 #include <support/check.h>
23 #include <support/xunistd.h>
27 /* Handler for SIGUSR1. */
29 sigusr1_handler (int signo
)
31 TEST_VERIFY (signo
== SIGUSR1
);
34 /* Spawn a subprocess to send two signals: First SIGUSR1, then
35 SIGUSR2. Return the PID of the process. */
42 static const struct timespec delay
= { 1, };
43 if (nanosleep (&delay
, NULL
) != 0)
44 FAIL_EXIT1 ("nanosleep: %m");
45 if (kill (getppid (), SIGUSR1
) != 0)
46 FAIL_EXIT1 ("kill (SIGUSR1): %m");
47 if (nanosleep (&delay
, NULL
) != 0)
48 FAIL_EXIT1 ("nanosleep: %m");
49 if (kill (getppid (), SIGUSR2
) != 0)
50 FAIL_EXIT1 ("kill (SIGUSR2): %m");
59 if (signal (SIGUSR1
, sigusr1_handler
) == SIG_ERR
)
60 FAIL_EXIT1 ("signal (SIGUSR1): %m\n");
64 sigaddset (&sigs
, SIGUSR2
);
65 if (sigprocmask (SIG_BLOCK
, &sigs
, NULL
) != 0)
66 FAIL_EXIT1 ("sigprocmask (SIGBLOCK, SIGUSR2): %m");
67 pid_t pid
= signal_sender ();
69 int ret
= sigwait (&sigs
, &signo
);
72 support_record_failure ();
74 printf ("error: sigwait failed: %m (%d)\n", ret
);
76 TEST_VERIFY (signo
== SIGUSR2
);
79 xwaitpid (pid
, &status
, 0);
80 TEST_VERIFY (status
== 0);
85 #include <support/test-driver.c>