| --- a/Lib/test/regrtest.py |
| +++ b/Lib/test/regrtest.py |
| @@ -160,21 +160,28 @@ To enable all resources except one, use |
| example, to run all the tests except for the gui tests, give the |
| option '-uall,-gui'. |
| """ |
| +USAGE_SIGUSR1 = """ |
| +You can send a SIGUSR1 signal to display the tracebacks of the current threads. |
| +Note that sending a signal may interrupt a system call in progress and thus |
| +interfere with the tests, so only do it if a test hangs and you want to know |
| +where. |
| +""" |
| import builtins |
| +import errno |
| import faulthandler |
| import getopt |
| +import io |
| import json |
| import os |
| import random |
| import re |
| -import io |
| +import signal |
| import sys |
| import time |
| -import errno |
| import traceback |
| +import unittest |
| import warnings |
| -import unittest |
| from inspect import isabstract |
| import tempfile |
| import platform |
| @@ -268,6 +275,8 @@ def main(tests=None, testdir=None, verbo |
| # Display the Python traceback fatal errors (e.g. segfault) |
| faulthandler.enable(all_threads=True) |
| + if hasattr(signal, 'SIGUSR1'): |
| + faulthandler.register(signal.SIGUSR1) |
| if hasattr(faulthandler, 'dump_tracebacks_later'): |
| timeout = 60*60 |
| @@ -297,7 +306,10 @@ def main(tests=None, testdir=None, verbo |
| start = None |
| for o, a in opts: |
| if o in ('-h', '--help'): |
| - print(__doc__) |
| + usage = __doc__ |
| + if hasattr(signal, 'SIGUSR1'): |
| + usage += USAGE_SIGUSR1 |
| + print(usage) |
| return |
| elif o in ('-v', '--verbose'): |
| verbose += 1 |