Treat a tty read failure like EOF as it usually means the pty has
gone away. Handle write() on the tty returning EIO.
This commit is contained in:
@@ -437,16 +437,15 @@ perform_io(fd_set *fdsr, fd_set *fdsw, struct command_status *cstat)
|
|||||||
} while (n == -1 && errno == EINTR);
|
} while (n == -1 && errno == EINTR);
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case -1:
|
case -1:
|
||||||
if (errno == EAGAIN)
|
if (errno != EAGAIN) {
|
||||||
break;
|
/* treat read error as fatal and close the fd */
|
||||||
if (errno != ENXIO && errno != EBADF) {
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR,
|
sudo_debug_printf(SUDO_DEBUG_ERROR,
|
||||||
"error reading fd %d: %s", iob->rfd,
|
"error reading fd %d: %s", iob->rfd,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
errors++;
|
safe_close(iob->rfd);
|
||||||
break;
|
iob->rfd = -1;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
/* got EOF or pty has gone away */
|
/* got EOF or pty has gone away */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
@@ -469,7 +468,7 @@ perform_io(fd_set *fdsr, fd_set *fdsw, struct command_status *cstat)
|
|||||||
iob->len - iob->off);
|
iob->len - iob->off);
|
||||||
} while (n == -1 && errno == EINTR);
|
} while (n == -1 && errno == EINTR);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
if (errno == EPIPE || errno == ENXIO || errno == EBADF) {
|
if (errno == EPIPE || errno == ENXIO || errno == EIO || errno == EBADF) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"unable to write %d bytes to fd %d",
|
"unable to write %d bytes to fd %d",
|
||||||
iob->len - iob->off, iob->wfd);
|
iob->len - iob->off, iob->wfd);
|
||||||
|
Reference in New Issue
Block a user