diff options
author | Anton Lindqvist <anton@cvs.openbsd.org> | 2021-09-09 17:36:35 +0000 |
---|---|---|
committer | Anton Lindqvist <anton@cvs.openbsd.org> | 2021-09-09 17:36:35 +0000 |
commit | bec7d2dfa0ed2dada5d27719c2c8790a3ba3fd34 (patch) | |
tree | ef4cf1aee393393af686e055e32d5e5402e8a2be /regress/lib/libc | |
parent | 6b384b8295dc1081b710eeda7af274714f4938e8 (diff) |
Ensure that the kill signal undergoing testing is not ignored.
ok bluhm@
Diffstat (limited to 'regress/lib/libc')
-rw-r--r-- | regress/lib/libc/sys/t_fork.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/regress/lib/libc/sys/t_fork.c b/regress/lib/libc/sys/t_fork.c index 04157efc5dc..b28ee9dc558 100644 --- a/regress/lib/libc/sys/t_fork.c +++ b/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) { |