mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
bcbacfebf4
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
38 lines
849 B
Raku
38 lines
849 B
Raku
#require no-windows
|
|
|
|
$ cat > sleep.py << 'EOF'
|
|
> import os
|
|
> with open("pid", "w") as f:
|
|
> f.write("%s\n" % os.getpid())
|
|
> b.sleep(100)
|
|
> EOF
|
|
|
|
$ ( hg dbsh sleep.py && echo exited; ) >out 2>err &
|
|
$ disown
|
|
|
|
$ cat > interrupt.py << 'EOF'
|
|
> import time, os, signal, sys
|
|
> for tick in range(1000):
|
|
> if not os.path.exists("pid") or not open("pid").read():
|
|
> time.sleep(1)
|
|
> pid = int(open("pid").read())
|
|
> os.kill(pid, signal.SIGINT)
|
|
> 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!" printed by dispatch.py:
|
|
|
|
$ cat err
|
|
interrupted!
|
|
|
|
Should not have "exited" printed by "echo exited" because non-zero exit code:
|
|
|
|
$ cat out
|