Simplify the exec_monitor() foreground flag.
Add cmnd_foreground flag that is only true if sudo is the foreground process and the CD_EXEC_BG flag is not set and pass it to exec_monitor(). This means exec_monitor() no longer needs to check for CD_EXEC_BG.
This commit is contained in:
@@ -373,7 +373,7 @@ exec_cmnd_pty(struct command_details *details, sigset_t *mask,
|
||||
close(io_fds[SFD_STDERR]);
|
||||
|
||||
/* Wait for parent to grant us the tty if we are foreground. */
|
||||
if (foreground && !ISSET(details->flags, CD_EXEC_BG)) {
|
||||
if (foreground) {
|
||||
struct timespec ts = { 0, 1000 }; /* 1us */
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG, "%s: waiting for controlling tty",
|
||||
__func__);
|
||||
@@ -653,7 +653,7 @@ exec_monitor(struct command_details *details, sigset_t *oset,
|
||||
setpgid(mc.cmnd_pid, mc.cmnd_pgrp);
|
||||
|
||||
/* Make the command the foreground process for the pty follower. */
|
||||
if (foreground && !ISSET(details->flags, CD_EXEC_BG)) {
|
||||
if (foreground) {
|
||||
if (tcsetpgrp(io_fds[SFD_FOLLOWER], mc.cmnd_pgrp) == -1) {
|
||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO,
|
||||
"%s: unable to set foreground pgrp to %d (command)",
|
||||
|
Reference in New Issue
Block a user