rsync and tcsh don't play well on Cygwin

Mark Riley
Thu Apr 19 18:05:00 GMT 2007

After having problems with rsync (2.6.6) hanging while pushing files
to a Cygwin machine over ssh, I searched the lists here and found
that many other users were experiencing the same problem.  While
some solutions seemed to mitigate the problem, there are still some
users experiencing this problem (myself included).

After wading through massive(!) strace output files, it appears that 
an interaction between tcsh and rsync on the remote Cygwin machine
is the culprit.  If the remote machine is configured to use bash as the
login shell, then the problem disappears - rsync works fine.  This
might explain why some users can't reproduce the problem (they don't
use tcsh).

When rsync connects to the remote machine using ssh, sshd launches
a login shell (tcsh in this case) before the remote rsync command is run.
Perusing the source for tcsh, it can be seen that tsch calls setmode(fd,
O_TEXT) on the pipe supplied to it by sshd.  When rsync is subsequently
invoked, it inherits this pipe.  Rsync apparently assumes it is getting an
O_BINARY pipe and fails miserably when \r\n combinations are
translated to \n.

Recompiling rsync with

    setmode(STDIN_FILENO, O_BINARY);

placed near the beginning of main() fixes the problem and I can now
use tcsh as my login shell on the remote machine again.

This may not be the ideal solution, but other solutions I've tried like
putting "binmode" in the CYGWIN environment variable on the remote
machine or invoking rsync with the --rsh="ssh -T" option didn't

Anyway, I hope this solution works for some of the others out there
experiencing this problem.


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list