summaryrefslogtreecommitdiff
path: root/regress/sys/kern
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-09-20 16:39:41 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-09-20 16:39:41 +0000
commit5bdefdcafbfaec669b179f01acddbd4894eca22b (patch)
tree2c73a87df0f371404c984b760dfd0ac53644a85f /regress/sys/kern
parent9b0a92203b80b94f366603736a21850d52aaebc7 (diff)
Use proper sigsuspend() instead of old pause() and use sigprocmask() to
block delivery of signals outside of sigsuspend(). With this the test is more reliable. pause() is implemented as two syscalls and so it is possible to catch a signal on the first syscall and than be stuck on the second waiting for something that already happened. OK millert@ deraadt@ bluhm@
Diffstat (limited to 'regress/sys/kern')
-rw-r--r--regress/sys/kern/signal/signal-stress/signal-stress.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/regress/sys/kern/signal/signal-stress/signal-stress.c b/regress/sys/kern/signal/signal-stress/signal-stress.c
index 5a75d34ea42..9d3ac363f16 100644
--- a/regress/sys/kern/signal/signal-stress/signal-stress.c
+++ b/regress/sys/kern/signal/signal-stress/signal-stress.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal-stress.c,v 1.1 2020/09/16 14:02:24 mpi Exp $ */
+/* $OpenBSD: signal-stress.c,v 1.2 2021/09/20 16:39:40 claudio Exp $ */
/*
* Written by Artur Grabowski <art@openbsd.org> 2004 Public Domain.
*/
@@ -33,6 +33,7 @@ void
do_child(void)
{
int i;
+ sigset_t mask, oldmask;
/*
* Step 1 - suspend and wait for SIGCONT so that all siblings have
@@ -57,11 +58,17 @@ do_child(void)
signal(SIGUSR1, sighand);
signal(SIGUSR2, sighand);
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGUSR1);
+ sigaddset(&mask, SIGUSR2);
+
+ sigprocmask(SIG_BLOCK, &mask, &oldmask);
+
/* Step 2 - wait again until everyone is ready. */
raise(SIGSTOP);
while (usr1 < nsigs || usr2 < nsigs)
- pause();
+ sigsuspend(&oldmask);
/* Step 3 - wait again until everyone is ready. */
raise(SIGSTOP);