mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 06:47:41 +03:00
dispatch: ensure SIGINT triggers KeyboardInterrupt
Summary: It seems OSX python2 has SIGINT handler set to SIG_IGN by default when running inside tests. Detect that and reset SIGINT handler to raise KeyboardInterrupt. This fixes test-ctrl-c.t on OSX. As we're here, improve test-ctrl-c.t so it checks a bit more things and run quicker. Reviewed By: DurhamG Differential Revision: D23853455 fbshipit-source-id: 05c47650bc80f9880f724828d307c32786265e2c
This commit is contained in:
parent
f7f91ceabc
commit
bcbacfebf4
@ -540,6 +540,11 @@ def _runcatch(req):
|
||||
util.signal(num, catchterm)
|
||||
except ValueError:
|
||||
pass # happens if called in a thread
|
||||
# In some cases, SIGINT handler is set to SIG_IGN on OSX.
|
||||
# Reset it to raise KeyboardInterrupt.
|
||||
sigint = getattr(signal, "SIGINT", None)
|
||||
if sigint is not None and util.getsignal(sigint) == signal.SIG_IGN:
|
||||
util.signal(sigint, signal.default_int_handler)
|
||||
|
||||
realcmd = None
|
||||
try:
|
||||
|
@ -17,12 +17,21 @@
|
||||
> time.sleep(1)
|
||||
> pid = int(open("pid").read())
|
||||
> os.kill(pid, signal.SIGINT)
|
||||
> time.sleep(10)
|
||||
> try:
|
||||
> for _ in range(30):
|
||||
> os.kill(pid, 0) # raise if pid no loner exists
|
||||
> time.sleep(1)
|
||||
> except Exception:
|
||||
> pass
|
||||
> EOF
|
||||
|
||||
$ hg debugpython -- interrupt.py
|
||||
|
||||
Should have "interrupted!":
|
||||
Should have "interrupted!" printed by dispatch.py:
|
||||
|
||||
$ cat err
|
||||
interrupted!
|
||||
|
||||
Should not have "exited" printed by "echo exited" because non-zero exit code:
|
||||
|
||||
$ cat out
|
||||
|
Loading…
Reference in New Issue
Block a user