aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2011-01-21 23:44:13 +0000
committerTiago Cunha <tcunha@gmx.com>2011-01-21 23:44:13 +0000
commit492e3aa4373f0f20a8685cfb3591a9730bb0454a (patch)
tree3f11c4b5b3b68706442324e1be636c07e25d3db5 /tty.c
parent6b19621112c2fccdcde88f864291ef0939820b0d (diff)
downloadrtmux-492e3aa4373f0f20a8685cfb3591a9730bb0454a.tar.gz
rtmux-492e3aa4373f0f20a8685cfb3591a9730bb0454a.tar.bz2
rtmux-492e3aa4373f0f20a8685cfb3591a9730bb0454a.zip
Sync OpenBSD patchset 834:
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.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/tty.c b/tty.c
index 935ffd9c..a45a6099 100644
--- a/tty.c
+++ b/tty.c
@@ -1,4 +1,4 @@
-/* $Id: tty.c,v 1.199 2011-01-07 14:34:45 tcunha Exp $ */
+/* $Id: tty.c,v 1.200 2011-01-21 23:44:13 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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