]> granicus.if.org Git - sudo/commitdiff
If select() return EBADF in the main event loop, one of the ttys
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 Apr 2012 16:39:46 +0000 (12:39 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 Apr 2012 16:39:46 +0000 (12:39 -0400)
must have gone away so perform any I/O we can and close the bad
fds.

src/exec.c

index 5af8f0203c27fff7494e19d9b88cc391959366e5..36175e2a634bf689e7e919e0efa673bce4129645 100644 (file)
@@ -337,6 +337,10 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
        if (nready == -1) {
            if (errno == EINTR)
                continue;
+           if (errno == EBADF) {
+               /* One of the ttys must have gone away. */
+               goto do_tty_io;
+           }
            error(1, _("select failed"));
        }
        if (FD_ISSET(sv[0], fdsw)) {
@@ -403,7 +407,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
                break;
            }
        }
-
+do_tty_io:
        if (perform_io(fdsr, fdsw, cstat) != 0) {
            /* I/O error, kill child if still alive and finish. */
            sudo_debug_printf(SUDO_DEBUG_ERROR, "I/O error, terminating child");