default --rsh

Paul Slootman paul at debian.org
Wed Dec 17 08:45:12 EST 2003


I'm all for making it use ssh as default.

That said, I've noticed (at least when using -e ssh) that if ssh prompts
for a password or such, and you hit ctrl-c, you're more often than not
left with a tty with screwed up settings.  This is because ssh turns off
echo and such for asking the password, and hitting ctrl-c will trigger
the rsync's cleanup code, which may kill the child (i.e. ssh) before it
itself has had a chance to clean up. In fact, this was also reported as
a bug on the Debian package at one time.

Inserting a short delay completely solves the problem for me.
The patch is below. I'd like to see this go into 2.6.0 if possible.


Paul Slootman


--- rsync-2.5.7.orig/cleanup.c
+++ rsync-2.5.7/cleanup.c
@@ -104,6 +104,16 @@
 
 	if (cleanup_child_pid != -1) {
 		int status;
+                /* if the user hits ctrl-C while ssh is prompting for a password,
+                 * then the kill_all() below may kill ssh before ssh has a
+                 * chance to restore the tty settings (i.e. turn echo back on).
+                 * By sleeping for a short time, ssh gets a bigger chance to
+                 * do the right thing. When ssh exits, the select() in msleep()
+                 * will be interrupted by SIGCHLD anyway.
+                 * If child processes are not ssh waiting for a password, then
+                 * this tiny delay shouldn't hurt anything.
+                 */
+                msleep(400);
 		if (waitpid(cleanup_child_pid, &status, WNOHANG) == cleanup_child_pid) {
 			status = WEXITSTATUS(status);
 			if (status > code) code = status;



More information about the rsync mailing list