Truncated output from "rsync -e ssh ... 2>&1 | tee"

Wayne Davison wayned at samba.org
Tue Sep 28 16:46:46 GMT 2004


On Tue, Sep 28, 2004 at 04:10:13PM +0000, David Evers wrote:
>     rsync -e ssh -avn host:/path /local/path 2>&1 | tee LOG

In my test I piped the output to "(sleep 10; tail)" to ensure a
reproducable truncation.

The attached patch fixes the problem by putting our stderr fd back
into blocking I/O mode.  I don't see why ssh should be playing with
our stderr fd in the first place (since we're the one calling ssh,
not the one being run by ssh).  Does anyone see a problem with this
change?

..wayne..
-------------- next part --------------
--- main.c	17 Sep 2004 16:50:53 -0000	1.217
+++ main.c	28 Sep 2004 16:42:09 -0000
@@ -657,6 +657,9 @@ int client_run(int f_in, int f_out, pid_
 	if (protocol_version >= 23 && !read_batch)
 		io_start_multiplex_in();
 
+	/* Work around a bug in ssh that sets our STDERR to non-blocking. */
+	set_blocking(STDERR_FILENO);
+
 	if (am_sender) {
 		keep_dirlinks = 0; /* Must be disabled on the sender. */
 		io_start_buffering_out();


More information about the rsync mailing list