##// END OF EJS Templates
make_tarball.py fixes
make_tarball.py fixes

File last commit:

r477:cf729373
r479:5caf7612
Show More
ipy_signals.py
44 lines | 1.1 KiB | text/x-python | PythonLexer
""" Advanced signal (e.g. ctrl+C) handling for IPython
So far, this only ignores ctrl + C in IPython file a subprocess
is executing, to get closer to how a "proper" shell behaves.
Other signal processing may be implemented later on.
If _ip.options.verbose is true, show exit status if nonzero
"""
import signal,os
import IPython.ipapi
import subprocess
ip = IPython.ipapi.get()
def new_ipsystem(cmd):
""" ctrl+c ignoring replacement for system() command in iplib.
Ignore ctrl + c in IPython process during the command execution.
The subprocess will still get the ctrl + c signal.
"""
p = subprocess.Popen(cmd, shell = True)
old_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
pid,status = os.waitpid(p.pid,0)
signal.signal(signal.SIGINT, old_handler)
if status and ip.options.verbose:
print "[exit status: %d]" % status
def init():
o = ip.options
try:
o.verbose
except AttributeError:
o.allow_new_attr (True )
o.verbose = 0
ip.IP.system = new_ipsystem
init()