summaryrefslogtreecommitdiffstats
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-01-08 01:52:36 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-01-08 01:52:36 +0000
commit69cb1f830e4fd2282ddcbc7ee2bbe30069b9e4cd (patch)
tree49efff28238bbba524974db0512859a310d0b09c /tty.c
parent703160b5d6b64e45a684894260693c60b5524d51 (diff)
Move all calls to fcntl(...O_NONBLOCK) into a function and clear the
flag on the stdio file descriptors before closing them (fixes things like "tmux ls && cat").
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/tty.c b/tty.c
index 80afa2d4..451a5df6 100644
--- a/tty.c
+++ b/tty.c
@@ -165,15 +165,11 @@ void
tty_start_tty(struct tty *tty)
{
struct termios tio;
- int mode;
if (tty->fd == -1)
return;
- if ((mode = fcntl(tty->fd, F_GETFL)) == -1)
- fatal("fcntl failed");
- if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1)
- fatal("fcntl failed");
+ setblocking(tty->fd, 0);
bufferevent_enable(tty->event, EV_READ|EV_WRITE);
@@ -220,7 +216,6 @@ void
tty_stop_tty(struct tty *tty)
{
struct winsize ws;
- int mode;
if (!(tty->flags & TTY_STARTED))
return;
@@ -251,8 +246,7 @@ tty_stop_tty(struct tty *tty)
tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));
- if ((mode = fcntl(tty->fd, F_GETFL)) != -1)
- fcntl(tty->fd, F_SETFL, mode & ~O_NONBLOCK);
+ setblocking(tty->fd, 1);
}
void