Blame SOURCES/0064-script-be-sensitive-to-another-SIGCHLD-ssi_codes.patch

e377cc
From 84009d2236c73efe7dc4b74372734d5b3306670b Mon Sep 17 00:00:00 2001
e377cc
From: Karel Zak <kzak@redhat.com>
e377cc
Date: Wed, 5 Sep 2018 11:51:22 +0200
e377cc
Subject: [PATCH 64/72] script: be sensitive to another SIGCHLD ssi_codes
e377cc
e377cc
The current signalfd handler cares on CLD_EXITED only. It's pretty
e377cc
insufficient as there is more situations (and codes) when child no
e377cc
more running.
e377cc
e377cc
Addresses: https://github.com/karelzak/util-linux/issues/686
e377cc
Upstream: http://github.com/util-linux/util-linux/commit/27afe5016842c22d256ea9f88b598d637ca0df84
e377cc
Signed-off-by: Karel Zak <kzak@redhat.com>
e377cc
---
e377cc
 term-utils/script.c | 10 ++++++++--
e377cc
 1 file changed, 8 insertions(+), 2 deletions(-)
e377cc
e377cc
diff --git a/term-utils/script.c b/term-utils/script.c
e377cc
index d5ffa27f1..ff5f808de 100644
e377cc
--- a/term-utils/script.c
e377cc
+++ b/term-utils/script.c
e377cc
@@ -402,10 +402,15 @@ static void handle_signal(struct script_control *ctl, int fd)
e377cc
 
e377cc
 	switch (info.ssi_signo) {
e377cc
 	case SIGCHLD:
e377cc
-		DBG(SIGNAL, ul_debug(" get signal SIGCHLD"));
e377cc
-		if (info.ssi_code == CLD_EXITED) {
e377cc
+		DBG(SIGNAL, ul_debug(" get signal SIGCHLD [ssi_code=%d, ssi_status=%d]",
e377cc
+							info.ssi_code, info.ssi_status));
e377cc
+		if (info.ssi_code == CLD_EXITED
e377cc
+		    || info.ssi_code == CLD_KILLED
e377cc
+		    || info.ssi_code == CLD_DUMPED) {
e377cc
 			wait_for_child(ctl, 0);
e377cc
 			ctl->poll_timeout = 10;
e377cc
+
e377cc
+		/* In case of ssi_code is CLD_TRAPPED, CLD_STOPPED, or CLD_CONTINUED */
e377cc
 		} else if (info.ssi_status == SIGSTOP && ctl->child) {
e377cc
 			DBG(SIGNAL, ul_debug(" child stop by SIGSTOP -- stop parent too"));
e377cc
 			kill(getpid(), SIGSTOP);
e377cc
@@ -433,6 +438,7 @@ static void handle_signal(struct script_control *ctl, int fd)
e377cc
 	default:
e377cc
 		abort();
e377cc
 	}
e377cc
+	DBG(SIGNAL, ul_debug("signal handle on FD %d done", fd));
e377cc
 }
e377cc
 
e377cc
 static void do_io(struct script_control *ctl)
e377cc
-- 
e377cc
2.31.1
e377cc