Revision: 2828
          http://tmux.svn.sourceforge.net/tmux/?rev=2828&view=rev
Author:   tcunha
Date:     2012-06-18 15:25:23 +0000 (Mon, 18 Jun 2012)
Log Message:
-----------
Sync OpenBSD patchset 1139:

Actually write all the data to stdout/stderr.

Modified Paths:
--------------
    trunk/client.c

Modified: trunk/client.c
===================================================================
--- trunk/client.c      2012-06-18 15:24:17 UTC (rev 2827)
+++ trunk/client.c      2012-06-18 15:25:23 UTC (rev 2828)
@@ -58,6 +58,7 @@
 void           client_update_event(void);
 void           client_signal(int, short, void *);
 void           client_stdin_callback(int, short, void *);
+void           client_write(int, const char *, size_t);
 void           client_callback(int, short, void *);
 int            client_dispatch_attached(void);
 int            client_dispatch_wait(void *);
@@ -460,6 +461,24 @@
        client_update_event();
 }
 
+/* Force write to file descriptor. */
+void
+client_write(int fd, const char *data, size_t size)
+{
+       ssize_t used;
+
+       while (size != 0) {
+               used = write(fd, data, size);
+               if (used == -1) {
+                       if (errno == EINTR || errno == EAGAIN)
+                               continue;
+                       break;
+               }
+               data += used;
+               size -= used;
+       }
+}
+
 /* Dispatch imsgs when in wait state (before MSG_READY). */
 int
 client_dispatch_wait(void *data)
@@ -504,14 +523,14 @@
                                fatalx("bad MSG_STDOUT");
                        memcpy(&stdoutdata, imsg.data, sizeof stdoutdata);
 
-                       fwrite(stdoutdata.data, stdoutdata.size, 1, stdout);
+                       client_write(STDOUT_FILENO, stdoutdata.data, 
stdoutdata.size);
                        break;
                case MSG_STDERR:
                        if (datalen != sizeof stderrdata)
                                fatalx("bad MSG_STDERR");
                        memcpy(&stderrdata, imsg.data, sizeof stderrdata);
 
-                       fwrite(stderrdata.data, stderrdata.size, 1, stderr);
+                       client_write(STDERR_FILENO, stderrdata.data, 
stderrdata.size);
                        break;
                case MSG_VERSION:
                        if (datalen != 0)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to