From 4cac34b86d8e99d44456088b2d9a1913bb059ef4 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 3 May 2022 09:38:28 -0600 Subject: [PATCH] Make SIGCHLD handler more consistent with the pty version. No real change other than a few debug statements. --- src/exec_nopty.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/exec_nopty.c b/src/exec_nopty.c index 97ef31957..01c41bb9c 100644 --- a/src/exec_nopty.c +++ b/src/exec_nopty.c @@ -542,7 +542,6 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec) /* There may be multiple children in intercept mode. */ for (;;) { - /* Read command status. */ do { pid = waitpid(-1, &status, wflags); } while (pid == -1 && errno == EINTR); @@ -566,7 +565,7 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec) if (sig2str(signo, signame) == -1) (void)snprintf(signame, sizeof(signame), "%d", signo); sudo_debug_printf(SUDO_DEBUG_INFO, - "%s: command (%d) stopped, SIG%s", __func__, (int)pid, signame); + "%s: process %d stopped, SIG%s", __func__, (int)pid, signame); if (ISSET(ec->details->flags, CD_USE_PTRACE)) { /* Did exec_ptrace_handled() suppress the signal? */ @@ -574,8 +573,8 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec) continue; } - /* Only report status for the main command. */ - if (ec->cmnd_pid != pid) + /* Special handling for job control in the main command only. */ + if (pid != ec->cmnd_pid) continue; /* @@ -654,11 +653,11 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec) WTERMSIG(status)); } sudo_debug_printf(SUDO_DEBUG_INFO, - "%s: command (%d) killed, SIG%s", __func__, + "%s: process %d killed, SIG%s", __func__, (int)pid, signame); } else if (WIFEXITED(status)) { sudo_debug_printf(SUDO_DEBUG_INFO, - "%s: command (%d) exited: %d", __func__, + "%s: process %d exited: %d", __func__, (int)pid, WEXITSTATUS(status)); } else { sudo_debug_printf(SUDO_DEBUG_WARN, @@ -666,8 +665,8 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec) __func__, status, (int)pid); } - /* Only report status for the main command. */ - if (ec->cmnd_pid != pid) + /* Only store exit status of the main command. */ + if (pid != ec->cmnd_pid) continue; /* Don't overwrite execve() failure with command exit status. */