From: Todd C. Miller Date: Thu, 5 Apr 2012 16:39:46 +0000 (-0400) Subject: If select() return EBADF in the main event loop, one of the ttys X-Git-Tag: SUDO_1_8_5~1^2~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f4afc66522f12061aac63e0fdf2f44e844ba40b;p=sudo If select() return EBADF in the main event loop, one of the ttys must have gone away so perform any I/O we can and close the bad fds. --- diff --git a/src/exec.c b/src/exec.c index 5af8f0203..36175e2a6 100644 --- a/src/exec.c +++ b/src/exec.c @@ -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");