From be2b9de39572847afdcb1ce9e44d916361311506 Mon Sep 17 00:00:00 2001 From: anton Date: Thu, 29 Jul 2021 15:33:18 +0000 Subject: 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(-) (limited to 'regress/lib/libc') diff --git a/regress/lib/libc/sys/t_kill.c b/regress/lib/libc/sys/t_kill.c index 2f30b062ca7..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 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); } } -- cgit v1.2.3