Skip to content


Don't kill paramiko tunnels when receiving ^C #2526

merged 1 commit into from

4 participants


prevents ^C from being passed along to children, bringing them down

closes #2520


This version of spawn_pgrp seems to be modified quite heavily to call it an adaption and not a dependency of IPython.
Would it make sense to add such adaptions to IPython/adaptions instead of IPython/external?

It would be more clear, if there is a folder of copy&pasted dependencies in one folder, that live there for the sake of simplifying installing/running IPython, but are not (heavy) modified for use of IPython.


What do you mean by modified quite heavily? The original file has two things:

  1. a generic subclass of pexpect.spawn that exposes setpgrp
  2. a utility function specific to the gridmon project

All I did was delete the function, as it makes no sense to keep it (trying to call it would just result in an ImportError). The class is unmodified.

But in #2520 @andreabedini said this doesn't even fix the issue (which I don't fully understand), so I think we should probably just close this and try something else.


I realized that this problem never affected the pexpect case, so I've scrubbed the whole setpgrp thing. All that was needed here was signal.signal(signal.SIGINT, signal.SIG_IGN) in the tunnel function called in the forked process.


Do we wait for feedback from the author @andreabedini?


This last patch fixes the problem for me. Thanks heaps.


Great. Merging.

@Carreau Carreau merged commit ecf061e into ipython:master

1 check passed

Details default The Travis build passed

Thanks, @Carreau and @andreabedini!

@minrk minrk referenced this pull request from a commit
@minrk minrk Backport PR #2526: Don't kill paramiko tunnels when receiving ^C
prevents ^C from being passed along to children, bringing them down

closes #2520
@minrk minrk deleted the minrk:setpgrp branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 7, 2012
  1. @minrk
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 3 deletions.
  1. +5 −3 IPython/external/ssh/
8 IPython/external/ssh/
@@ -22,6 +22,7 @@
from __future__ import print_function
import os,sys, atexit
+import signal
import socket
from multiprocessing import Process
from getpass import getpass, getuser
@@ -331,9 +332,10 @@ def _paramiko_tunnel(lport, rport, server, remoteip, keyfile=None, password=None
except Exception as e:
print ('*** Failed to connect to %s:%d: %r' % (server, port, e))
- # print ('Now forwarding port %d to %s:%d ...' % (lport, server, rport))
+ # Don't let SIGINT kill the tunnel subprocess
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
forward_tunnel(lport, remoteip, rport, client.get_transport())
except KeyboardInterrupt:
Something went wrong with that request. Please try again.