tty settings with rsync -e ssh interrupt

jw schultz jw at pegasys.ws
Fri Feb 7 09:03:23 EST 2003


On Thu, Feb 06, 2003 at 04:19:36PM -0500, Hardy Merrill wrote:
> jw schultz [jw at pegasys.ws] wrote:
> > On Thu, Feb 06, 2003 at 03:46:11PM -0500, Hardy Merrill wrote:
> > > I'm following up on a bug reported back in May 2002:
> > > 
> > >   https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=64689
> > > 
> > > this bug was also reported to the rsync mailing list:
> > > 
> > >   http://www.mail-archive.com/rsync@lists.samba.org/mail5.html#04250
> > > 
> > > I couldn't find any discussion other than the reporters post
> > > describing the problem.
> > > 
> > > Anyway, I just downloaded the new rsync-2.5.6 source, installed
> > > it, and found that the bug still exists.  This problem shows
> > > itself when using "-e ssh", and Ctrl-C'ing at the ssh password
> > > prompt - the terminal gets screwed up.
> > > 
> > > Anyone have any insight on this?
> > > 
> > > Thanks.
> > > 
> > > -- 
> > > Hardy Merrill
> > > Senior Software Engineer
> > > Red Hat, Inc.
> > 
> > Blame ssh.  It is failing to restore the tty settings.
> 
> Please excuse my naivete - I'm a relative newbie to rsync - how
> come when you run ssh by itself and Ctrl-C at the password
> prompt, your terminal is fine?  Why is it only affected when
> run with -e from rsync?

Sorry. Don't blame ssh.  Rsync is messing things up.

I've attached a cleaned up strace output.

What is happening is that both rsync and ssh get the SIGINT.
Unfortunately, before ssh has had a sufficient chance to
process the SIGINT rsync sends it a SIGUSR1 as part of
cleanup.  ssh doesn't catch SIGUSR1 so it just exits.

This is the first i've looked at this part of rsync so i'd
be cautious about changing any of the timings.  However, it
does seem to me that a more correct behavior on receiving a
SIGINT would be to forward that to the children and give
them a chance to clean up before sending any more signals.

-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw at pegasys.ws

		Remember Cernan and Schmitt
-------------- next part --------------
rsync	 rt_sigaction(SIGUSR1, {0x8050cc0, [USR1], SA_RESTART|0x4000000}, {SIG_DFL}, 8) = 0
rsync	 rt_sigaction(SIGUSR2, {0x8050ce0, [USR2], SA_RESTART|0x4000000}, {SIG_DFL}, 8) = 0
rsync	 rt_sigaction(SIGCHLD, {0x8050d10, [CHLD], SA_RESTART|0x4000000}, {SIG_DFL}, 8) = 0
rsync	 rt_sigaction(SIGINT, {0x804a840, [INT], SA_RESTART|0x4000000}, {SIG_DFL}, 8) = 0
rsync	 rt_sigaction(SIGHUP, {0x804a840, [HUP], SA_RESTART|0x4000000}, {SIG_DFL}, 8) = 0
rsync	 rt_sigaction(SIGTERM, {0x804a840, [TERM], SA_RESTART|0x4000000}, {SIG_DFL}, 8) = 0
rsync	 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
rsync	 fork()                            = [ssh-pid]
ssh	execve("/usr/bin/ssh", ["ssh", "-l", "pgsql", "leto", "rsync", "--server", "--sender", "-logDtpr", ".", "/etc"], [/* 65 vars */]) = 0
ssh	rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_IGN}, 8) = 0
ssh	fcntl64(3, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
ssh	open("/dev/tty", O_RDWR|O_LARGEFILE) = 4
ssh	rt_sigaction(SIGINT, {0x806f04c, [], 0x4000000}, {SIG_DFL}, 8) = 0
ssh	rt_sigaction(SIGHUP, {0x806f04c, [], 0x4000000}, {SIG_DFL}, 8) = 0
ssh	rt_sigaction(SIGQUIT, {0x806f04c, [], 0x4000000}, {SIG_DFL}, 8) = 0
ssh	rt_sigaction(SIGTERM, {0x806f04c, [], 0x4000000}, {SIG_DFL}, 8) = 0
ssh	rt_sigaction(SIGTSTP, {0x806f04c, [], 0x4000000}, {SIG_DFL}, 8) = 0
ssh	rt_sigaction(SIGTTIN, {0x806f04c, [], 0x4000000}, {SIG_DFL}, 8) = 0
ssh	rt_sigaction(SIGTTOU, {0x806f04c, [], 0x4000000}, {SIG_DFL}, 8) = 0
ssh	ioctl(4, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ssh	ioctl(4, TCSETSF, {B38400 opost isig icanon -echo ...}) = 0
ssh	write(4, "pgsql at leto\'s password: ", 23) = 23
ssh	read(4,  <unfinished ...>
rsync	 <... select resumed> )            = ? ERESTARTNOHAND (To be restarted)
ssh	<... read resumed> 0xbfffe783, 1) = ? ERESTARTSYS (To be restarted)
rsync	 --- SIGINT (Interrupt) ---
rsync	 rt_sigaction(SIGUSR1, {SIG_IGN},  <unfinished ...>
ssh	--- SIGINT (Interrupt) ---
rsync	 <... rt_sigaction resumed> {0x8050cc0, [USR1], SA_RESTART|0x4000000}, 8) = 0
ssh	sigreturn( <unfinished ...>
rsync	 rt_sigaction(SIGUSR2, {SIG_IGN},  <unfinished ...>
ssh	<... sigreturn resumed> )         = ? (mask now [RTMIN])
rsync	 <... rt_sigaction resumed> {0x8050ce0, [USR2], SA_RESTART|0x4000000}, 8) = 0
ssh	write(4, "\n", 1 <unfinished ...>
rsync	 wait4([ssh-pid],  <unfinished ...>
ssh	<... write resumed> )             = 1
rsync	 <... wait4 resumed> 0xbfffeb00, WNOHANG, NULL) = -1 ECHILD (No child processes)
ssh	ioctl(4, TCSETSF <unfinished ...>
rsync	 getpid( <unfinished ...>
ssh	<... ioctl resumed> , {B38400 opost isig icanon echo ...}) = 0
rsync	 <... getpid resumed> )            = 17409
ssh	rt_sigaction(SIGINT, {SIG_DFL},  <unfinished ...>
rsync	 kill([ssh-pid], SIGUSR1 <unfinished ...>
ssh	<... rt_sigaction resumed> NULL, 8) = 0
rsync	 <... kill resumed> )              = 0
ssh	--- SIGUSR1 (User defined signal 1) ---
rsync	 write(2, "rsync error: received SIGUSR1 or"..., 66) = 66
rsync	 _exit(20)                         = ?


More information about the rsync mailing list