@@ -492,19 +492,19 @@ def set_pid():
492492 return pid
493493
494494
495- def interrupt_kernel_hack ():
496- import signal
497- send_kernel_interrupt (signal.SIGINT)
498495def terminate_kernel_hack ():
496+ " Send SIGTERM to our the IPython kernel"
499497 import signal
500- send_kernel_interrupt (signal.SIGTERM)
501- def send_kernel_interrupt (signal_to_send):
498+ interrupt_kernel_hack (signal.SIGTERM)
499+
500+ def interrupt_kernel_hack (signal_to_send= None):
502501 " ""
503502 Sends the interrupt signal to the remote kernel. This side steps the
504503 (non- functional) ipython interrupt mechanisms.
505504 Only works on posix.
506505 " ""
507506 global pid
507+ import signal
508508 import os
509509 if pid is None:
510510 # Avoid errors if we couldn't get pid originally,
@@ -514,10 +514,13 @@ def send_kernel_interrupt(signal_to_send):
514514 if pid is None:
515515 echo (" cannot get kernel PID, Ctrl-C will not be supported" )
516516 return
517+ if not signal_to_send:
518+ signal_to_send = signal.SIGINT
519+
517520 echo (" KeyboardInterrupt (sent to ipython: pid " +
518- " %i with signal %i )" % (pid, signal_to_send),"Operator")
521+ " %i with signal %s )" % (pid, signal_to_send),"Operator")
519522 try :
520- os.kill (pid, signal_to_send)
523+ os.kill (pid, int ( signal_to_send) )
521524 except OSError:
522525 echo (" unable to kill pid %d" % pid)
523526 pid = None
@@ -650,7 +653,7 @@ endif
650653command ! -nargs =* IPython :py km_from_string (" <args>" )
651654command ! -nargs =0 IPythonClipboard :py km_from_string (vim .eval (' @+' ))
652655command ! -nargs =0 IPythonXSelection :py km_from_string (vim .eval (' @*' ))
653- command ! -nargs =0 IPythonInterrupt :py interrupt_kernel_hack ()
656+ command ! -nargs =* IPythonInterrupt :py interrupt_kernel_hack (" <args> " )
654657command ! -nargs =0 IPythonTerminate :py terminate_kernel_hack ()
655658
656659function ! IPythonBalloonExpr ()
0 commit comments