[paramiko] ctrl-c issue.
James Bardin
jbardin at bu.edu
Mon Jan 7 06:22:47 PST 2008
Christian Vest Hansen wrote:
>
> Steps to reproduce:
> * connect to some server with normal ssh and $echo a >> my_file
> * then use above program to connect to the same server and run $tail -f my_file
> * then $echo b >> my_file and see the tail working
> * then, in the shell with above program still running, press ctrl-c
> * notice that pressing ctrl-c dosn't stop above program, regardless of
> how long you wait
> * now, in the normal ssh, do $echo c >> my_file
> * only then will above program notice the term request and halt operation
>
> What I want is for the program to terminate immediately when I press
> ctrl-c, so the question is how I can I make this so?
>
>
>
Your crtl-c is being sent to the local process, not the remote. The
local process say "ok, I'll quit when I'm done reading." The remote
process doesn't see any of this, so you're sort of in a deadlock.
Ctrl-c is just a SIGINT, so you could send a `kill -2 $PID` along
another channel to kill the remote process, or use an interactive
session so the term can send the signals.
You can also catch the interrupt locally, and call close() on the
transport (or SSHClient, which in turn calls the transport), which will
just disconnect you, and the remote program will "probably" just quit.
-jim
More information about the paramiko
mailing list