mirror of
https://github.com/tmux/tmux.git
synced 2024-11-04 18:08:48 +00:00
Accept tcgetattr/tcsetattr failure, fixes problems with fatal() if the
terminal disappears while locked.
This commit is contained in:
parent
b6bb350289
commit
9fc2c34a3b
7
tty.c
7
tty.c
@ -166,15 +166,13 @@ tty_start_tty(struct tty *tty)
|
|||||||
{
|
{
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
|
|
||||||
if (tty->fd == -1)
|
if (tty->fd == -1 || tcgetattr(tty->fd, &tty->tio) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setblocking(tty->fd, 0);
|
setblocking(tty->fd, 0);
|
||||||
|
|
||||||
bufferevent_enable(tty->event, EV_READ|EV_WRITE);
|
bufferevent_enable(tty->event, EV_READ|EV_WRITE);
|
||||||
|
|
||||||
if (tcgetattr(tty->fd, &tty->tio) != 0)
|
|
||||||
fatal("tcgetattr failed");
|
|
||||||
memcpy(&tio, &tty->tio, sizeof tio);
|
memcpy(&tio, &tty->tio, sizeof tio);
|
||||||
tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|IMAXBEL|ISTRIP);
|
tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|IMAXBEL|ISTRIP);
|
||||||
tio.c_iflag |= IGNBRK;
|
tio.c_iflag |= IGNBRK;
|
||||||
@ -183,8 +181,7 @@ tty_start_tty(struct tty *tty)
|
|||||||
ECHOPRT|ECHOKE|ECHOCTL|ISIG);
|
ECHOPRT|ECHOKE|ECHOCTL|ISIG);
|
||||||
tio.c_cc[VMIN] = 1;
|
tio.c_cc[VMIN] = 1;
|
||||||
tio.c_cc[VTIME] = 0;
|
tio.c_cc[VTIME] = 0;
|
||||||
if (tcsetattr(tty->fd, TCSANOW, &tio) != 0)
|
if (tcsetattr(tty->fd, TCSANOW, &tio) == 0)
|
||||||
fatal("tcsetattr failed");
|
|
||||||
tcflush(tty->fd, TCIOFLUSH);
|
tcflush(tty->fd, TCIOFLUSH);
|
||||||
|
|
||||||
tty_putcode(tty, TTYC_SMCUP);
|
tty_putcode(tty, TTYC_SMCUP);
|
||||||
|
Loading…
Reference in New Issue
Block a user