summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2011-01-08 01:52:36 +0000
committernicm <nicm@openbsd.org>2011-01-08 01:52:36 +0000
commita0ee42549e7fbfd1cf31458e1926b09c07492922 (patch)
treece276070f9ff977a91ddacaa8e83f2276ed2d437 /usr.bin/tmux/tty.c
parentdestatic. ok deraadt (diff)
downloadwireguard-openbsd-a0ee42549e7fbfd1cf31458e1926b09c07492922.tar.xz
wireguard-openbsd-a0ee42549e7fbfd1cf31458e1926b09c07492922.zip
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 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index f3704f3b4d0..9ef1f7c9304 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.95 2011/01/03 23:35:22 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.96 2011/01/08 01:52:37 nicm 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