Commit 2c5cf691 authored by Joanne Hugé's avatar Joanne Hugé

Change the way signals are handled

Make it so that the demo can be interrupted while a test is running
parent 0f97c026
...@@ -43,10 +43,19 @@ with open(os.devnull, "wb") as f: ...@@ -43,10 +43,19 @@ with open(os.devnull, "wb") as f:
# m1-m2-m3-m4-m5-m6-m7-m8 m10 # m1-m2-m3-m4-m5-m6-m7-m8 m10
# :2:: :4:: :6:: :8:: # :2:: :4:: :6:: :8::
def disable_signal_on_children(sig): # When request_stop is true, subprocess know they need to exit
pid = os.getpid() # and execute their exit routine
sigint = signal.signal(sig, lambda *x: os.getpid() == pid and sigint(*x)) request_stop = False
disable_signal_on_children(signal.SIGINT) pid = os.getpid()
sigint = signal.getsignal(signal.SIGINT)
def sigint_handler(*x):
global request_stop
if os.getpid() == pid:
request_stop = True
sigint(*x)
signal.signal(signal.SIGINT, sigint_handler)
Node__add_interface = nemu.Node._add_interface Node__add_interface = nemu.Node._add_interface
def _add_interface(node, iface): def _add_interface(node, iface):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment