diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -427,7 +427,13 @@ def _run_and_join(self, script): script = """if 1: - import sys, os, time, threading + import sys, os, time, threading, signal + + try: + import faulthandler + faulthandler.enable() + except (ImportError, AttributeError): + pass # a thread, which waits for the main program to terminate def joiningfunc(mainthread): @@ -482,8 +488,13 @@ def worker(): childpid = os.fork() if childpid != 0: - os.waitpid(childpid, 0) - sys.exit(0) + for i in range(10): + pid, _ = os.waitpid(childpid, os.WNOHANG) + if pid == childpid: + sys.exit(0) + time.sleep(1) + os.kill(childpid, signal.SIGABRT) + os._exit(1) t = threading.Thread(target=joiningfunc, args=(main_thread,))