mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 06:17:04 +00:00
Don't attempt to reset tty if it is dead.
This commit is contained in:
42
tty.c
42
tty.c
@ -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) {
|
||||
|
Reference in New Issue
Block a user