1
""" Advanced signal (e.g. ctrl+C) handling for IPython
3
So far, this only ignores ctrl + C in IPython file a subprocess
4
is executing, to get closer to how a "proper" shell behaves.
6
Other signal processing may be implemented later on.
8
If _ip.options.verbose is true, show exit status if nonzero
16
ip = IPython.ipapi.get()
18
def new_ipsystem_posix(cmd):
19
""" ctrl+c ignoring replacement for system() command in iplib.
21
Ignore ctrl + c in IPython process during the command execution.
22
The subprocess will still get the ctrl + c signal.
27
p = subprocess.Popen(cmd, shell = True)
29
old_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
30
pid,status = os.waitpid(p.pid,0)
31
signal.signal(signal.SIGINT, old_handler)
32
if status and ip.options.verbose:
33
print "[exit status: %d]" % status
35
def new_ipsystem_win32(cmd):
36
""" ctrl+c ignoring replacement for system() command in iplib.
38
Ignore ctrl + c in IPython process during the command execution.
39
The subprocess will still get the ctrl + c signal.
43
old_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
44
status = os.system(cmd)
45
signal.signal(signal.SIGINT, old_handler)
46
if status and ip.options.verbose:
47
print "[exit status: %d]" % status
54
except AttributeError:
55
o.allow_new_attr (True )
58
ip.IP.system = (sys.platform == 'win32' and new_ipsystem_win32 or
b'\\ No newline at end of file'