Don't attempt to reset tty if it is dead.

This commit is contained in:
Nicholas Marriott 2008-01-02 19:22:21 +00:00
parent 34b7810afe
commit ccfeb316a6
3 changed files with 32 additions and 20 deletions

View File

@ -1,3 +1,7 @@
02 January 2008
* Don't attempt to reset the tty on exit if it has been closed externally.
06 December 2007
* Restore checks for required termcap entries and add a few more obvious
@ -299,4 +303,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.91 2007-12-06 11:05:04 nicm Exp $
$Id: CHANGES,v 1.92 2008-01-02 19:22:21 nicm Exp $

42
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.17 2007-12-16 17:18:43 nicm Exp $ */
/* $Id: tty.c,v 1.18 2008-01-02 19:22:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -124,22 +124,28 @@ tty_close(struct tty *tty)
if (tty->fd == -1)
return;
if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1)
fatal("ioctl(TIOCGWINSZ)");
if (tcsetattr(tty->fd, TCSANOW, &tty->tio) != 0)
fatal("tcsetattr failed");
if (change_scroll_region != NULL)
tty_raw(tty, tparm(change_scroll_region, 0, ws.ws_row - 1));
if (keypad_local != NULL)
tty_raw(tty, keypad_local);
if (exit_ca_mode != NULL)
tty_raw(tty, exit_ca_mode);
tty_raw(tty, clear_screen);
if (cursor_normal != NULL)
tty_raw(tty, cursor_normal);
if (exit_attribute_mode != NULL)
tty_raw(tty, exit_attribute_mode);
/*
* Skip any writing if the fd is invalid. Things like ssh -t can
* easily leave us with a dead tty.
*/
if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1) {
if (errno != EBADF && errno != ENXIO)
fatal("ioctl(TIOCGWINSZ)");
} else {
if (tcsetattr(tty->fd, TCSANOW, &tty->tio) != 0)
fatal("tcsetattr failed");
tty_raw(tty, tparm(change_scroll_region, 0, ws.ws_row - 1));
if (keypad_local != NULL)
tty_raw(tty, keypad_local);
if (exit_ca_mode != NULL)
tty_raw(tty, exit_ca_mode);
tty_raw(tty, clear_screen);
if (cursor_normal != NULL)
tty_raw(tty, cursor_normal);
if (exit_attribute_mode != NULL)
tty_raw(tty, exit_attribute_mode);
}
tty_free_term(tty->term);
tty_keys_free(tty);
@ -336,6 +342,8 @@ tty_vwrite(struct tty *tty, unused struct screen *s, int cmd, va_list ap)
char ch;
u_int i, ua, ub;
if (tty->term == NULL) /* XXX XXX */
return;
set_curterm(tty->term->term);
switch (cmd) {

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.34 2007-12-06 10:04:43 nicm Exp $ */
/* $Id: window.c,v 1.35 2008-01-02 19:22:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -47,7 +47,7 @@
* server poll loop. Output data is received from pty's in screen format,
* translated and returned as a series of escape sequences and strings via
* input_parse (in input.c). Input data is received as key codes and written
* directly via input_translate_key.
* directly via input_key.
*
* Each window also has a "virtual" screen (screen.c) which contains the
* current state and is redisplayed when the window is reattached to a client.