summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2011-01-29 08:39:44 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2011-01-29 08:39:44 +0000
commitaccda9cc27d9be64a72b19bbadd9e0f8678d3a4c (patch)
tree41937e1ef94d4007b85e1b036eadea685e15c3d2 /usr.bin/tmux
parentffb7c505af851437edd58b358899635ae3d39478 (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.c11
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);