From c8c586ee0bc6299869ac357792eb19bed8a56329 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 15 Jun 2017 07:51:00 -0600 Subject: [PATCH] Better handling of SIGCONT from in command in the monitor. It is useful to know when the command continued but we don't want to inform the parent or store the wait status in this case. Fixes a hang after multiple suspends on Linux. --- src/exec_monitor.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/exec_monitor.c b/src/exec_monitor.c index c52833edd..47b0227dc 100644 --- a/src/exec_monitor.c +++ b/src/exec_monitor.c @@ -196,17 +196,20 @@ mon_handle_sigchld(struct monitor_closure *mc) if (mc->cstat->type == CMD_INVALID) { /* * Store wait status in cstat and forward to parent if stopped. + * Parent does not expect SIGCONT so don't bother sending it. */ - mc->cstat->type = CMD_WSTATUS; - mc->cstat->val = status; - if (WIFSTOPPED(status)) { - /* Save the foreground pgid so we can restore it later. */ - do { - pid = tcgetpgrp(io_fds[SFD_SLAVE]); - } while (pid == -1 && errno == EINTR); - if (pid != mc->mon_pgrp) - mc->cmnd_pgrp = pid; - send_status(mc->backchannel, mc->cstat); + if (!WIFCONTINUED(status)) { + mc->cstat->type = CMD_WSTATUS; + mc->cstat->val = status; + if (WIFSTOPPED(status)) { + /* Save the foreground pgid so we can restore it later. */ + do { + pid = tcgetpgrp(io_fds[SFD_SLAVE]); + } while (pid == -1 && errno == EINTR); + if (pid != mc->mon_pgrp) + mc->cmnd_pgrp = pid; + send_status(mc->backchannel, mc->cstat); + } } } -- 2.40.0