Make SIGCHLD handler more consistent with the pty version.
No real change other than a few debug statements.
This commit is contained in:
@@ -542,7 +542,6 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec)
|
|||||||
|
|
||||||
/* There may be multiple children in intercept mode. */
|
/* There may be multiple children in intercept mode. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* Read command status. */
|
|
||||||
do {
|
do {
|
||||||
pid = waitpid(-1, &status, wflags);
|
pid = waitpid(-1, &status, wflags);
|
||||||
} while (pid == -1 && errno == EINTR);
|
} while (pid == -1 && errno == EINTR);
|
||||||
@@ -566,7 +565,7 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec)
|
|||||||
if (sig2str(signo, signame) == -1)
|
if (sig2str(signo, signame) == -1)
|
||||||
(void)snprintf(signame, sizeof(signame), "%d", signo);
|
(void)snprintf(signame, sizeof(signame), "%d", signo);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
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)) {
|
if (ISSET(ec->details->flags, CD_USE_PTRACE)) {
|
||||||
/* Did exec_ptrace_handled() suppress the signal? */
|
/* Did exec_ptrace_handled() suppress the signal? */
|
||||||
@@ -574,8 +573,8 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only report status for the main command. */
|
/* Special handling for job control in the main command only. */
|
||||||
if (ec->cmnd_pid != pid)
|
if (pid != ec->cmnd_pid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -654,11 +653,11 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec)
|
|||||||
WTERMSIG(status));
|
WTERMSIG(status));
|
||||||
}
|
}
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: command (%d) killed, SIG%s", __func__,
|
"%s: process %d killed, SIG%s", __func__,
|
||||||
(int)pid, signame);
|
(int)pid, signame);
|
||||||
} else if (WIFEXITED(status)) {
|
} else if (WIFEXITED(status)) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: command (%d) exited: %d", __func__,
|
"%s: process %d exited: %d", __func__,
|
||||||
(int)pid, WEXITSTATUS(status));
|
(int)pid, WEXITSTATUS(status));
|
||||||
} else {
|
} else {
|
||||||
sudo_debug_printf(SUDO_DEBUG_WARN,
|
sudo_debug_printf(SUDO_DEBUG_WARN,
|
||||||
@@ -666,8 +665,8 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec)
|
|||||||
__func__, status, (int)pid);
|
__func__, status, (int)pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only report status for the main command. */
|
/* Only store exit status of the main command. */
|
||||||
if (ec->cmnd_pid != pid)
|
if (pid != ec->cmnd_pid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Don't overwrite execve() failure with command exit status. */
|
/* Don't overwrite execve() failure with command exit status. */
|
||||||
|
Reference in New Issue
Block a user