From: claudio Date: Mon, 20 Sep 2021 16:39:40 +0000 (+0000) Subject: Use proper sigsuspend() instead of old pause() and use sigprocmask() to X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9ce1dae7baf5c5af25d77155d8f97c69540f5cb0;p=openbsd 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@ --- 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 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);