diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-22 10:29:32 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-22 10:29:32 +0000 |
commit | e73e1c0ae5a14766b7936f16006ef0d3edcedafb (patch) | |
tree | a55c78a9960aaaa505472767643cd509e555d79d | |
parent | 17b5c2b7c4ea92aa7c3954f1b968bf0895308e41 (diff) |
I strongly suspect it is possible for tmux to block on detach in
tty_raw, so make the fd blocking again much later and have tty_raw just
retry the write a few times.
-rw-r--r-- | usr.bin/tmux/tty.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index c0a57031525..2390bfaf11e 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.149 2013/03/21 18:44:47 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.150 2013/03/22 10:29:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -267,8 +267,6 @@ tty_stop_tty(struct tty *tty) if (tcsetattr(tty->fd, TCSANOW, &tty->tio) == -1) return; - setblocking(tty->fd, 1); - tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1)); if (tty_use_acs(tty)) tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS)); @@ -288,6 +286,8 @@ tty_stop_tty(struct tty *tty) tty_raw(tty, "\033[?1000l"); tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP)); + + setblocking(tty->fd, 1); } void @@ -332,7 +332,21 @@ tty_free(struct tty *tty) void tty_raw(struct tty *tty, const char *s) { - write(tty->fd, s, strlen(s)); + ssize_t n, slen; + u_int i; + + slen = strlen(s); + for (i = 0; i < 5; i++) { + n = write(tty->fd, s, slen); + if (n >= 0) { + s += n; + slen -= n; + if (slen == 0) + break; + } else if (n == -1 && errno != EAGAIN) + break; + usleep(100); + } } void |