Close the pty slave in the parent so that when the command and

monitor exit, the pty gets recycled without our having to close
it directly.
This commit is contained in:
Todd C. Miller
2018-08-20 10:04:15 -06:00
parent 6953e7fc79
commit 5cca421867
2 changed files with 40 additions and 28 deletions

View File

@@ -594,6 +594,15 @@ exec_monitor(struct command_details *details, sigset_t *oset,
if (pipe2(errpipe, O_CLOEXEC) != 0)
sudo_fatal(U_("unable to create pipe"));
/*
* Before forking, wait for the main sudo process to tell us to go.
* Avoids race conditions when the command exits quickly.
*/
while (recv(backchannel, &cstat, sizeof(cstat), MSG_WAITALL) == -1) {
if (errno != EINTR && errno != EAGAIN)
sudo_fatal(U_("unable to receive message from parent"));
}
mc.cmnd_pid = sudo_debug_fork();
switch (mc.cmnd_pid) {
case -1: