From 58d4b18b5c6fa0174ab459a1e96813c5050552af Mon Sep 17 00:00:00 2001 From: anton <> Date: Thu, 9 Sep 2021 17:36:34 +0000 Subject: Ensure that the kill signal undergoing testing is not ignored. ok bluhm@ --- src/regress/lib/libc/sys/t_fork.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/regress/lib/libc/sys/t_fork.c') diff --git a/src/regress/lib/libc/sys/t_fork.c b/src/regress/lib/libc/sys/t_fork.c index 04157efc5d..b28ee9dc55 100644 --- a/src/regress/lib/libc/sys/t_fork.c +++ b/src/regress/lib/libc/sys/t_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_fork.c,v 1.2 2021/09/02 15:28:41 mbuhl Exp $ */ +/* $OpenBSD: t_fork.c,v 1.3 2021/09/09 17:36:34 anton Exp $ */ /* $NetBSD: t_fork.c,v 1.4 2019/04/06 15:41:54 kamil Exp $ */ /*- @@ -142,10 +142,21 @@ await_stopped_child(pid_t process) static void raise_raw(int sig) { + struct sigaction act, oact; int rv, status; pid_t child, parent, watcher, wpid; int expect_core = (sig == SIGABRT) ? 1 : 0; + /* Ensure the signal is not ignored. */ + if (sig != SIGKILL && sig != SIGSTOP) { + memset(&act, 0, sizeof(act)); + act.sa_handler = SIG_DFL; + ATF_REQUIRE(sigaction(sig, &act, &oact) == 0); + } else { + ATF_REQUIRE(sigaction(sig, &act, &oact) != 0); + ATF_REQUIRE(errno == EINVAL); + } + /* * Spawn a dedicated thread to watch for a stopped child and emit * the SIGKILL signal to it. @@ -203,6 +214,9 @@ raise_raw(int sig) } wpid = waitpid(child, &status, 0); + if (sig != SIGKILL && sig != SIGSTOP) + ATF_REQUIRE(sigaction(sig, &oact, NULL) == 0); + ATF_REQUIRE_EQ(wpid, child); switch (sig) { -- cgit v1.2.3-55-g6feb