From 8e80ba2a19d7fd89c3e3848cc06f201c9a542a5a Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 11 Dec 2022 04:46:42 -0600 Subject: [PATCH] Child process running recursive command shouldn't inherit SIGCHLD handler. --- toys/other/timeout.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toys/other/timeout.c b/toys/other/timeout.c index d0c93ccd..ed4956a4 100644 --- a/toys/other/timeout.c +++ b/toys/other/timeout.c @@ -49,20 +49,19 @@ static long nantomil(struct timespec *ts) static void callback(char *argv[]) { + xsignal(SIGCHLD, SIG_DFL); if (!FLAG(foreground)) setpgid(0, 0); } void timeout_main(void) { - int ii, ms, nextsig; + int ii, ms, nextsig = SIGTERM; struct timespec tts, kts; // Use same ARGFAIL value for any remaining parsing errors toys.exitval = 125; xparsetimespec(*toys.optargs, &tts); if (TT.k) xparsetimespec(TT.k, &kts); - - nextsig = SIGTERM; if (TT.s && -1==(nextsig = sig_to_num(TT.s))) error_exit("bad -s: '%s'",TT.s); toys.exitval = 0; @@ -70,6 +69,7 @@ void timeout_main(void) TT.fds[1] = -1; if (sigsetjmp(TT.sj, 1)) goto done; xsignal_flags(SIGCHLD, handler, SA_NOCLDSTOP); + TT.pid = xpopen_setup(toys.optargs+1, FLAG(i) ? TT.fds : 0, callback); xsignal(SIGTTIN, SIG_IGN); xsignal(SIGTTOU, SIG_IGN); -- 2.39.2