Don't die on any error from fd.

This commit is contained in:
Nicholas Marriott 2009-02-17 18:53:10 +00:00
parent ca8b6a08ff
commit 546a9d5257

18
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.78 2009-02-16 19:01:16 nicm Exp $ */ /* $Id: tty.c,v 1.79 2009-02-17 18:53:10 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -187,15 +187,12 @@ tty_stop_tty(struct tty *tty)
* because the fd is invalid. Things like ssh -t can easily leave us * because the fd is invalid. Things like ssh -t can easily leave us
* with a dead tty. * with a dead tty.
*/ */
if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1) { if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1)
if (errno != EBADF && errno != ENXIO && errno != ENOTTY) return;
fatal("ioctl(TIOCGWINSZ)"); if (tcsetattr(tty->fd, TCSANOW, &tty->tio) == -1)
} else if (tcsetattr(tty->fd, TCSANOW, &tty->tio) == -1) { return;
if (errno != EBADF && errno != ENXIO && errno != ENOTTY)
fatal("tcsetattr failed"); tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1));
} else {
tty_raw(tty,
tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1));
tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS)); tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS));
tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0)); tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0));
tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR)); tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR));
@ -205,7 +202,6 @@ tty_stop_tty(struct tty *tty)
tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM)); tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
if (tty_term_has(tty->term, TTYC_KMOUS)) if (tty_term_has(tty->term, TTYC_KMOUS))
tty_raw(tty, "\033[?1000l"); tty_raw(tty, "\033[?1000l");
}
} }
void void