From ecf061e6b6a4334154ce67eb3253c004d4d2c2ea 2012-11-13 10:36:52 From: Bussonnier Matthias Date: 2012-11-13 10:36:52 Subject: [PATCH] Merge pull request #2526 from minrk/setpgrp Don't kill paramiko tunnels when receiving ^C --- diff --git a/IPython/external/ssh/tunnel.py b/IPython/external/ssh/tunnel.py index 9ae2311..c63f0ce 100644 --- a/IPython/external/ssh/tunnel.py +++ b/IPython/external/ssh/tunnel.py @@ -22,6 +22,7 @@ Authors 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)) sys.exit(1) - - # 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) + try: forward_tunnel(lport, remoteip, rport, client.get_transport()) except KeyboardInterrupt: