From: Todd C. Miller Date: Thu, 15 Jun 2017 13:51:00 +0000 (-0600) Subject: Better handling of SIGCONT from in command in the monitor. It is X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8c586ee0bc6299869ac357792eb19bed8a56329;p=sudo 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. --- 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); + } } }