]> granicus.if.org Git - sudo/commitdiff
Fix a hang introduced in the last commit. Don't close the pty slave
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 5 May 2017 20:45:35 +0000 (14:45 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 5 May 2017 20:45:35 +0000 (14:45 -0600)
until after we have the controlling tty.

src/exec_monitor.c

index f8a21a5cab910e110bd9d6f7c7f59606b084d048..b0cb389a71d14d0c35ec426e07b3c2f9af585da7 100644 (file)
@@ -408,8 +408,6 @@ exec_cmnd_pty(struct command_details *details, bool foreground, int errfd)
        if (io_fds[SFD_STDERR] != io_fds[SFD_SLAVE])
            close(io_fds[SFD_STDERR]);
     }
-    if (io_fds[SFD_SLAVE] != -1)
-       close(io_fds[SFD_SLAVE]);
 
     /* Wait for parent to grant us the tty if we are foreground. */
     if (foreground && !ISSET(details->flags, CD_EXEC_BG)) {
@@ -418,6 +416,10 @@ exec_cmnd_pty(struct command_details *details, bool foreground, int errfd)
            nanosleep(&ts, NULL);
     }
 
+    /* Done with the pty slave, don't leak it. */
+    if (io_fds[SFD_SLAVE] != -1)
+       close(io_fds[SFD_SLAVE]);
+
     /* Execute command; only returns on error. */
     exec_cmnd(details, errfd);