From 1db73a72041cdbbeb4ddef01595f25129a8138f7 Mon Sep 17 00:00:00 2001 From: Tom Greenslade Date: Thu, 29 Oct 2026 14:17:40 +0000 Subject: [PATCH] gh-160881: Fix test_is_python_process_non_python_subprocess with multicall sleep _wait_for_process_exec() waited for /proc/{pid}/exe to be named "sleep", which never happens when sleep is a multicall binary (BusyBox on Alpine, coreutils-single on RHEL UBI9). Wait instead until the child's executable differs from the parent's, which means the child has called exec(). Co-Authored-By: Claude Opus 5.5 --- .../test_sampling_profiler/test_children.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_profiling/test_sampling_profiler/test_children.py b/Lib/test/test_profiling/test_sampling_profiler/test_children.py index 4b27c6dbb1896c1..9a8d529c4b82444 100644 --- a/Lib/test/test_profiling/test_sampling_profiler/test_children.py +++ b/Lib/test/test_profiling/test_sampling_profiler/test_children.py @@ -85,12 +85,14 @@ def reader(): return result[0] -def _wait_for_process_exec(proc, name, timeout): +def _wait_for_process_exec(proc, timeout): # Wait until a child process calls exec() to replace the forked process - # executable. Raise AssertionError on timeout. + # executable. Don't check the executable name: it can be a multicall + # binary such as /bin/busybox. Raise AssertionError on timeout. + parent_exe = os.readlink("/proc/self/exe") for _ in sleeping_retry(timeout, max_delay=0.1): exe = os.readlink(f"/proc/{proc.pid}/exe") - if os.path.basename(exe) == name: + if exe != parent_exe: break @@ -625,7 +627,7 @@ def test_is_python_process_non_python_subprocess(self): ) try: - _wait_for_process_exec(proc, "sleep", SHORT_TIMEOUT) + _wait_for_process_exec(proc, SHORT_TIMEOUT) self.assertFalse( is_python_process(proc.pid),