From 1f4af99b5af2e09ebcf945e28fe18780fe92ba3e Mon Sep 17 00:00:00 2001 From: Davi de Jesus Date: Fri, 23 Oct 2026 18:19:57 -0300 Subject: [PATCH] gh-160295: Fix race in test_forkserver_sigkill (GH-160296) After a SIGKILL, the forkserver can no longer report the first child's exit status, so proc.join() returns with exit code 255 while the child may still be running. Wait for the event instead of checking it right after join(). (cherry picked from commit 40c8edd2ca1e8df67ae8a5f02a660ff3ce1f061b) Co-authored-by: Davi de Jesus --- Lib/test/_test_multiprocessing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 931fe4bcf891ae..887efe1a2a7b0a 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -993,7 +993,9 @@ def check_forkserver_death(self, signum): self.assertEqual(proc2.exitcode, 0) proc.join() - self.assertTrue(evt.is_set()) + # After SIGKILL, join() can return (exitcode 255) as soon as the + # status pipe is closed, before the orphaned child has run. + self.assertTrue(evt.wait(support.SHORT_TIMEOUT)) self.assertIn(proc.exitcode, (0, 255)) def test_forkserver_sigint(self):