patch to fix non-echo tty on scp SIGINT

Adam Wiggins hiro at dusk.org
Tue Dec 7 19:23:30 EST 2004


On Tue, Dec 07, 2004 at 12:44:24PM +1100, Darren Tucker wrote:
> Adam Wiggins wrote:
> >A long-time missing feature (or bug, depending on how you look at it) is
> >that a Ctrl-C at the password prompt in scp does not restore the
> >terminal settings, thus dropping you to the command prompt without any
> >keyboard echo.  (A "reset" command will fix it.)  This is a pretty
> >regular occurance for me, and some others I've talked to - usually when
> >you realize that the scp command you typed has a typo and decide to
> >abort.
> 
> Yeah, after a while "stty sane" gets old, doesn't it :-?

Although having the benefit of saving your screen contents, my method
gives a savings of N characters, where N is equal to:

echo `echo -n stty sane | wc -c` - `echo -n reset | wc -c` | bc

:)

> scp passes the signal to ssh then immediately exits.  ssh will then get 
> the passed signal (eg a SIGINT) plus a SIGPIPE (since the other end of 
> its stdin/stdout descriptors have closed).  Same applies to sftp too.
> 
> I think that in many cases the SIGPIPE is killing ssh before the SIGINT 
> handler has a chance to restore the terminal modes.  The attached patch 
> prevents this by waiting for ssh to exit before scp does.

All makes perfect sense, but the patch doesn't seem to change the
behavior on my system (Linux, kernel 2.6, KDE 3.3 terminal).  Just for
kicks I tried it on other terminals (xterm, gnome-terminal) on the same
system - all give the same result.

> The problem doesn't seem to occur on OpenBSD, however I'm not sure if 
> this is simply because the dice didn't come up right, or there's some 
> mechanism which prevents it (eg process scheduling or a different signal 
> delivery order).

Now, here's something: I just dropped back to the text console, and the
problem does not appear there.  The plot thickens: an "export TERM=linux"
command (to make it match the text console) in my KDE terminal fixes it
as well!  (The default for the KDE terminal, and the others, is "xterm".)

Darren, what's your term set to?  Maybe this is a termcap settings
problem rather than scp or the OS.

Adam




More information about the openssh-unix-dev mailing list