From: Karel Zak Date: Mon, 21 Sep 2020 10:51:02 +0000 (+0200) Subject: script: kill child process on error X-Git-Tag: v2.37-rc1~477 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8deb45fc5682c3ac0903a3e2b947ceedcc4ab7d6;p=thirdparty%2Futil-linux.git script: kill child process on error The recent change in code improves main-pool on error, but we need to kill child process if it still running to avoid hang up in next waitpid(). Signed-off-by: Karel Zak --- diff --git a/lib/pty-session.c b/lib/pty-session.c index 4cf29d6ddd..6d8ba4eb79 100644 --- a/lib/pty-session.c +++ b/lib/pty-session.c @@ -631,6 +631,12 @@ int ul_pty_proxy_master(struct ul_pty *pty) break; } + if (rc && pty->child && pty->child != (pid_t) -1 && !pty->delivered_signal) { + kill(pty->child, SIGTERM); + sleep(2); + kill(pty->child, SIGKILL); + } + pty_signals_cleanup(pty); DBG(IO, ul_debug("poll() done [signal=%d, rc=%d]", pty->delivered_signal, rc)); diff --git a/term-utils/script.c b/term-utils/script.c index c7f3250def..0a12dda4f2 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -673,7 +673,6 @@ static int callback_log_stream_activity(void *data, int fd, char *buf, size_t bu ctl->outsz += ssz; - /* check output limit */ if (ctl->maxsz != 0 && ctl->outsz >= ctl->maxsz) { if (!ctl->quiet)