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

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