diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-01-02 19:22:21 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-01-02 19:22:21 +0000 |
commit | ccfeb316a674370778390dc3192045fbe18113fe (patch) | |
tree | 6604967151f3507e1236e021c61ea60c0db7aee1 | |
parent | 34b7810afe016695b7445a5acfa796423734db56 (diff) | |
download | rtmux-ccfeb316a674370778390dc3192045fbe18113fe.tar.gz rtmux-ccfeb316a674370778390dc3192045fbe18113fe.tar.bz2 rtmux-ccfeb316a674370778390dc3192045fbe18113fe.zip |
Don't attempt to reset tty if it is dead.
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | tty.c | 42 | ||||
-rw-r--r-- | window.c | 4 |
3 files changed, 32 insertions, 20 deletions
@@ -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 $ @@ -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) { @@ -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. |