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

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