Skip to content

Commit 66e6fb6

Browse files
author
anton
committed
Ensure that the kill signal undergoing testing is not ignored.
ok bluhm@
1 parent 9617f81 commit 66e6fb6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/regress/lib/libc/sys/t_kill.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: t_kill.c,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */
1+
/* $OpenBSD: t_kill.c,v 1.2 2021/07/29 15:33:17 anton Exp $ */
22
/* $NetBSD: t_kill.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */
33

44
/*-
@@ -60,6 +60,17 @@ ATF_TC_BODY(kill_basic, tc)
6060
int sta;
6161

6262
for (i = 0; i < __arraycount(sig); i++) {
63+
struct sigaction act, oact;
64+
65+
/* Ensure the signal is not ignored. */
66+
if (sig[i] != SIGKILL) {
67+
memset(&act, 0, sizeof(act));
68+
act.sa_handler = SIG_DFL;
69+
ATF_REQUIRE(sigaction(sig[i], &act, &oact) == 0);
70+
} else {
71+
ATF_REQUIRE(sigaction(sig[i], &act, &oact) != 0);
72+
ATF_REQUIRE(errno == EINVAL);
73+
}
6374

6475
pid = fork();
6576
ATF_REQUIRE(pid >= 0);
@@ -78,6 +89,9 @@ ATF_TC_BODY(kill_basic, tc)
7889

7990
if (WIFSIGNALED(sta) == 0 || WTERMSIG(sta) != sig[i])
8091
atf_tc_fail("kill(2) failed to kill child");
92+
93+
if (sig[i] != SIGKILL)
94+
ATF_REQUIRE(sigaction(sig[i], &oact, NULL) == 0);
8195
}
8296
}
8397

0 commit comments

Comments
 (0)