]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
script: kill child process on error
authorKarel Zak <kzak@redhat.com>
Mon, 21 Sep 2020 10:51:02 +0000 (12:51 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 21 Sep 2020 10:58:46 +0000 (12:58 +0200)
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 <kzak@redhat.com>
lib/pty-session.c
term-utils/script.c

index 4cf29d6ddd2c8f37c72a5ff0057f1ffdcf58821e..6d8ba4eb792529ae3e3350229b5dfd4c298fe8eb 100644 (file)
@@ -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));
index c7f3250def9a6981601e67dd0efd85afa9878ccd..0a12dda4f2c0cbce3e3cc458b2262f86f310cd53 100644 (file)
@@ -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)