From 760d86cc637cc6dc520fa54e22b9e8c163c19752 Mon Sep 17 00:00:00 2001 From: anton Date: Thu, 29 Jul 2021 15:33:17 +0000 Subject: [PATCH] Ensure that the kill signal undergoing testing is not ignored. ok bluhm@ --- regress/lib/libc/sys/t_kill.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/regress/lib/libc/sys/t_kill.c b/regress/lib/libc/sys/t_kill.c index c92bbdd18bb..871427cb8d8 100644 --- a/regress/lib/libc/sys/t_kill.c +++ b/regress/lib/libc/sys/t_kill.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_kill.c,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */ +/* $OpenBSD: t_kill.c,v 1.2 2021/07/29 15:33:17 anton Exp $ */ /* $NetBSD: t_kill.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */ /*- @@ -60,6 +60,17 @@ ATF_TC_BODY(kill_basic, tc) int sta; for (i = 0; i < __arraycount(sig); i++) { + struct sigaction act, oact; + + /* Ensure the signal is not ignored. */ + if (sig[i] != SIGKILL) { + memset(&act, 0, sizeof(act)); + act.sa_handler = SIG_DFL; + ATF_REQUIRE(sigaction(sig[i], &act, &oact) == 0); + } else { + ATF_REQUIRE(sigaction(sig[i], &act, &oact) != 0); + ATF_REQUIRE(errno == EINVAL); + } pid = fork(); ATF_REQUIRE(pid >= 0); @@ -78,6 +89,9 @@ ATF_TC_BODY(kill_basic, tc) if (WIFSIGNALED(sta) == 0 || WTERMSIG(sta) != sig[i]) atf_tc_fail("kill(2) failed to kill child"); + + if (sig[i] != SIGKILL) + ATF_REQUIRE(sigaction(sig[i], &oact, NULL) == 0); } } -- 2.20.1