contrib/showstack.py
author Jun Wu <quark@fb.com>
Wed, 24 Feb 2016 14:24:00 +0000
changeset 28237 a3d73e069f8d
parent 26123 bdac264e5ed4
child 28522 f2fe7b199bb4
permissions -rw-r--r--
chg: extract gethgcmd logic to a function gethgcmd is to get original hg (not chg) binary name. This patch extracts the logic from execcmdserver to make it available for the following patch.

# showstack.py - extension to dump a Python stack trace on signal
#
# binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs)

import sys, signal, traceback

def sigshow(*args):
    sys.stderr.write("\n")
    traceback.print_stack(args[1], limit=10, file=sys.stderr)
    sys.stderr.write("----\n")

def extsetup(ui):
    signal.signal(signal.SIGQUIT, sigshow)
    try:
        signal.signal(signal.SIGINFO, sigshow)
    except AttributeError:
        pass