diff options
author | anton <> | 2021-09-09 17:36:34 +0000 |
---|---|---|
committer | anton <> | 2021-09-09 17:36:34 +0000 |
commit | 58d4b18b5c6fa0174ab459a1e96813c5050552af (patch) | |
tree | c6383d2d3e7ac83910372b675acc13a41c58e60e /src/regress/lib/libc/sys | |
parent | aa0e235cc622d59a481b0c6ac071a1ccaec2503e (diff) | |
download | openbsd-58d4b18b5c6fa0174ab459a1e96813c5050552af.tar.gz openbsd-58d4b18b5c6fa0174ab459a1e96813c5050552af.tar.bz2 openbsd-58d4b18b5c6fa0174ab459a1e96813c5050552af.zip |
Ensure that the kill signal undergoing testing is not ignored.
ok bluhm@
Diffstat (limited to 'src/regress/lib/libc/sys')
-rw-r--r-- | src/regress/lib/libc/sys/t_fork.c | 16 |
1 files changed, 15 insertions, 1 deletions
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 @@ | |||
1 | /* $OpenBSD: t_fork.c,v 1.2 2021/09/02 15:28:41 mbuhl Exp $ */ | 1 | /* $OpenBSD: t_fork.c,v 1.3 2021/09/09 17:36:34 anton Exp $ */ |
2 | /* $NetBSD: t_fork.c,v 1.4 2019/04/06 15:41:54 kamil Exp $ */ | 2 | /* $NetBSD: t_fork.c,v 1.4 2019/04/06 15:41:54 kamil Exp $ */ |
3 | 3 | ||
4 | /*- | 4 | /*- |
@@ -142,10 +142,21 @@ await_stopped_child(pid_t process) | |||
142 | static void | 142 | static void |
143 | raise_raw(int sig) | 143 | raise_raw(int sig) |
144 | { | 144 | { |
145 | struct sigaction act, oact; | ||
145 | int rv, status; | 146 | int rv, status; |
146 | pid_t child, parent, watcher, wpid; | 147 | pid_t child, parent, watcher, wpid; |
147 | int expect_core = (sig == SIGABRT) ? 1 : 0; | 148 | int expect_core = (sig == SIGABRT) ? 1 : 0; |
148 | 149 | ||
150 | /* Ensure the signal is not ignored. */ | ||
151 | if (sig != SIGKILL && sig != SIGSTOP) { | ||
152 | memset(&act, 0, sizeof(act)); | ||
153 | act.sa_handler = SIG_DFL; | ||
154 | ATF_REQUIRE(sigaction(sig, &act, &oact) == 0); | ||
155 | } else { | ||
156 | ATF_REQUIRE(sigaction(sig, &act, &oact) != 0); | ||
157 | ATF_REQUIRE(errno == EINVAL); | ||
158 | } | ||
159 | |||
149 | /* | 160 | /* |
150 | * Spawn a dedicated thread to watch for a stopped child and emit | 161 | * Spawn a dedicated thread to watch for a stopped child and emit |
151 | * the SIGKILL signal to it. | 162 | * the SIGKILL signal to it. |
@@ -203,6 +214,9 @@ raise_raw(int sig) | |||
203 | } | 214 | } |
204 | wpid = waitpid(child, &status, 0); | 215 | wpid = waitpid(child, &status, 0); |
205 | 216 | ||
217 | if (sig != SIGKILL && sig != SIGSTOP) | ||
218 | ATF_REQUIRE(sigaction(sig, &oact, NULL) == 0); | ||
219 | |||
206 | ATF_REQUIRE_EQ(wpid, child); | 220 | ATF_REQUIRE_EQ(wpid, child); |
207 | 221 | ||
208 | switch (sig) { | 222 | switch (sig) { |