diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-01-29 08:39:44 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-01-29 08:39:44 +0000 |
commit | accda9cc27d9be64a72b19bbadd9e0f8678d3a4c (patch) | |
tree | 41937e1ef94d4007b85e1b036eadea685e15c3d2 /usr.bin/tmux | |
parent | ffb7c505af851437edd58b358899635ae3d39478 (diff) |
Accept tcgetattr/tcsetattr failure, fixes problems with fatal() if the
terminal disappears while locked.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/tty.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 01018e0c2cf..2a49f1af055 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.98 2011/01/15 00:46:19 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.99 2011/01/29 08:39:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -166,15 +166,13 @@ tty_start_tty(struct tty *tty) { struct termios tio; - if (tty->fd == -1) + if (tty->fd == -1 || tcgetattr(tty->fd, &tty->tio) != 0) return; setblocking(tty->fd, 0); bufferevent_enable(tty->event, EV_READ|EV_WRITE); - if (tcgetattr(tty->fd, &tty->tio) != 0) - fatal("tcgetattr failed"); memcpy(&tio, &tty->tio, sizeof tio); tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|IMAXBEL|ISTRIP); tio.c_iflag |= IGNBRK; @@ -183,9 +181,8 @@ tty_start_tty(struct tty *tty) ECHOPRT|ECHOKE|ECHOCTL|ISIG); tio.c_cc[VMIN] = 1; tio.c_cc[VTIME] = 0; - if (tcsetattr(tty->fd, TCSANOW, &tio) != 0) - fatal("tcsetattr failed"); - tcflush(tty->fd, TCIOFLUSH); + if (tcsetattr(tty->fd, TCSANOW, &tio) == 0) + tcflush(tty->fd, TCIOFLUSH); tty_putcode(tty, TTYC_SMCUP); |