]> granicus.if.org Git - sudo/commitdiff
Better handling of SIGCONT from in command in the monitor. It is
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 15 Jun 2017 13:51:00 +0000 (07:51 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 15 Jun 2017 13:51:00 +0000 (07:51 -0600)
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

index c52833eddbd4298f02dd6f0bcb145f06ca1e8b32..47b0227dcaceb499582fbb036621171e168d259b 100644 (file)
@@ -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);
+           }
        }
     }