diff options
author | Karel Zak | 2018-09-05 11:51:22 +0200 |
---|---|---|
committer | Karel Zak | 2018-09-05 11:55:21 +0200 |
commit | 27afe5016842c22d256ea9f88b598d637ca0df84 (patch) | |
tree | 0118c0e826479f7595a174046de0f0159ea863f2 /term-utils | |
parent | lscpu: use the first VM from /proc/sysinfo (diff) | |
download | kernel-qcow2-util-linux-27afe5016842c22d256ea9f88b598d637ca0df84.tar.gz kernel-qcow2-util-linux-27afe5016842c22d256ea9f88b598d637ca0df84.tar.xz kernel-qcow2-util-linux-27afe5016842c22d256ea9f88b598d637ca0df84.zip |
script: be sensitive to another SIGCHLD ssi_codes
The current signalfd handler cares on CLD_EXITED only. It's pretty
insufficient as there is more situations (and codes) when child no
more running.
Addresses: https://github.com/karelzak/util-linux/issues/686
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils')
-rw-r--r-- | term-utils/script.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/term-utils/script.c b/term-utils/script.c index 6d5ddd84a..7692f91e2 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -477,10 +477,15 @@ static void handle_signal(struct script_control *ctl, int fd) switch (info.ssi_signo) { case SIGCHLD: - DBG(SIGNAL, ul_debug(" get signal SIGCHLD")); - if (info.ssi_code == CLD_EXITED) { + DBG(SIGNAL, ul_debug(" get signal SIGCHLD [ssi_code=%d, ssi_status=%d]", + info.ssi_code, info.ssi_status)); + if (info.ssi_code == CLD_EXITED + || info.ssi_code == CLD_KILLED + || info.ssi_code == CLD_DUMPED) { wait_for_child(ctl, 0); ctl->poll_timeout = 10; + + /* In case of ssi_code is CLD_TRAPPED, CLD_STOPPED, or CLD_CONTINUED */ } else if (info.ssi_status == SIGSTOP && ctl->child) { DBG(SIGNAL, ul_debug(" child stop by SIGSTOP -- stop parent too")); kill(getpid(), SIGSTOP); @@ -508,6 +513,7 @@ static void handle_signal(struct script_control *ctl, int fd) default: abort(); } + DBG(SIGNAL, ul_debug("signal handle on FD %d done", fd)); } static void do_io(struct script_control *ctl) |