diff --git a/Lib/test/test_perf_profiler.py b/Lib/test/test_perf_profiler.py index 597e6599352049..ae6bfe513eba81 100644 --- a/Lib/test/test_perf_profiler.py +++ b/Lib/test/test_perf_profiler.py @@ -116,11 +116,14 @@ def baz_fork(): def foo(): pid = os.fork() if pid == 0: - print(os.getpid()) + print(os.getpid(), flush=True) baz_fork() + os._exit(0) else: _, status = os.waitpid(-1, 0) - sys.exit(status) + if os.WIFSIGNALED(status): + sys.exit(1) + sys.exit(os.WEXITSTATUS(status)) def bar(): foo()