D4870: showstack: also handle SIGALRM
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Wed Oct 3 20:13:52 UTC 2018
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This is looking *very* handy when debugging mysterious hangs in a
test: you can wrap a hanging invocation in
`perl -e 'alarm shift @ARGV; exec @ARGV' 1`
for example, a hanging `hg pull` becomes
`perl -e 'alarm shift @ARGV; exec @ARGV' 1 hg pull`
where the `1` is the timeout in seconds before the process will be hit
with SIGALRM. After making that edit to the test file, you can then
use --extra-config-opt on run-tests.py to globaly enable showstack
during the test run, so you'll get full stack traces as you force your
hg to exit.
I wonder (but only a little, not enough to take action just yet) if we
should wire up some scaffolding in run-tests itself to automatically
wrap all commands in alarm(3) somehow to avoid hangs in the future?
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4870
AFFECTED FILES
contrib/showstack.py
CHANGE DETAILS
diff --git a/contrib/showstack.py b/contrib/showstack.py
--- a/contrib/showstack.py
+++ b/contrib/showstack.py
@@ -4,7 +4,7 @@
"""dump stack trace when receiving SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs)
"""
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import signal
import sys
import traceback
@@ -14,8 +14,14 @@
traceback.print_stack(args[1], limit=10, file=sys.stderr)
sys.stderr.write("----\n")
+def sigexit(*args):
+ sigshow(*args)
+ print('alarm!')
+ sys.exit(1)
+
def extsetup(ui):
signal.signal(signal.SIGQUIT, sigshow)
+ signal.signal(signal.SIGALRM, sigexit)
try:
signal.signal(signal.SIGINFO, sigshow)
except AttributeError:
To: durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list