The branch, master has been updated
       via  4c91c153cb087e1256578da1e53f002edefc9958 (commit)
      from  cf2c0237f49f31763b617e011e4fe73c3e710c9a (commit)

- Log -----------------------------------------------------------------
commit 4c91c153cb087e1256578da1e53f002edefc9958
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    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.
---
 tty.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/tty.c b/tty.c
index 378539c..892960f 100644
--- a/tty.c
+++ b/tty.c
@@ -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


-----------------------------------------------------------------------

Summary of changes:
 tty.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to