Title: `test_is_python_process_non_python_subprocess` always times out when `sleep` is a multicall binary (Alpine/BusyBox, RHEL UBI9) · Issue #160881 · python/cpython · GitHub
Open Graph Title: `test_is_python_process_non_python_subprocess` always times out when `sleep` is a multicall binary (Alpine/BusyBox, RHEL UBI9) · Issue #160881 · python/cpython
X Title: `test_is_python_process_non_python_subprocess` always times out when `sleep` is a multicall binary (Alpine/BusyBox, RHEL UBI9) · Issue #160881 · python/cpython
Description: Bug report Bug description: The fix for gh-159534 (GH-160028, backported to 3.15 in GH-160080) makes test_is_python_process_non_python_subprocess fail every time on systems where sleep is provided by a multicall binary. That includes the...
Open Graph Description: Bug report Bug description: The fix for gh-159534 (GH-160028, backported to 3.15 in GH-160080) makes test_is_python_process_non_python_subprocess fail every time on systems where sleep is provided ...
X Description: Bug report Bug description: The fix for gh-159534 (GH-160028, backported to 3.15 in GH-160080) makes test_is_python_process_non_python_subprocess fail every time on systems where sleep is provided ...
Opengraph URL: https://github.com/python/cpython/issues/160881
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`test_is_python_process_non_python_subprocess` always times out when `sleep` is a multicall binary (Alpine/BusyBox, RHEL UBI9)","articleBody":"### Bug report\n\n### Bug description:\n\nThe fix for gh-159534 (GH-160028, backported to 3.15 in GH-160080) makes `test_is_python_process_non_python_subprocess` fail every time on systems where `sleep` is provided by a multicall binary. That includes the Alpine buildbots, where the original gh-159534 failure was found:\n\n```\nFAIL: test_is_python_process_non_python_subprocess (test.test_profiling.test_sampling_profiler.test_children.TestIsPythonProcess.test_is_python_process_non_python_subprocess)\nTest that a non-Python subprocess is not detected as Python.\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \".../Lib/test/test_profiling/test_sampling_profiler/test_children.py\", line 628, in test_is_python_process_non_python_subprocess\n _wait_for_process_exec(proc, \"sleep\", SHORT_TIMEOUT)\n File \".../Lib/test/test_profiling/test_sampling_profiler/test_children.py\", line 91, in _wait_for_process_exec\n for _ in sleeping_retry(timeout, max_delay=0.1):\n File \".../Lib/test/support/__init__.py\", line 2779, in sleeping_retry\n for _ in busy_retry(timeout, err_msg, error=error):\n File \".../Lib/test/support/__init__.py\", line 2749, in busy_retry\n raise AssertionError(msg)\nAssertionError: timeout (45.1 seconds)\n```\n\n#### Buildbots\n\nAMD64 Alpine Linux NoGIL 3.x:\n- [build 3444](https://buildbot.python.org/#/builders/1819/builds/3444) (before GH-160028): the original intermittent failure, `True is not false`.\n- [build 3445](https://buildbot.python.org/#/builders/1819/builds/3445) (first build with GH-160028): `timeout (45.1 seconds)`. Every build since fails the same way, e.g. [build 3523](https://buildbot.python.org/#/builders/1819/builds/3523).\n\nAMD64 Alpine Linux 3.15:\n- [build 800](https://buildbot.python.org/#/builders/2114/builds/800) (before GH-160080): only `test_lazy_import` fails.\n- [build 815](https://buildbot.python.org/#/builders/2114/builds/815) (first build with GH-160080) and every build since, including [build 851](https://buildbot.python.org/#/builders/2114/builds/851) just before v3.15.2 was tagged: this test fails too.\n\nThis failure is separate from the `test_lazy_import` crash on Alpine (gh-159535). The Alpine builders will stay red after that crash is fixed.\n\n#### Cause\n\nThe new `_wait_for_process_exec()` helper waits until `os.path.basename(os.readlink(f\"/proc/{pid}/exe\")) == \"sleep\"`. When `sleep` is a multicall binary, `/proc/{pid}/exe` points to the multicall binary instead:\n\n| System | `/usr/bin/sleep` or `/bin/sleep` | `/proc/{pid}/exe` of a running `sleep` |\n|---|---|---|\n| Alpine 3.24 (BusyBox) | symlink to `/bin/busybox` | `/bin/busybox` |\n| RHEL UBI9 (`coreutils-single`, the image default) | shebang script `#!/usr/bin/coreutils --coreutils-prog-shebang=sleep` | `/usr/bin/coreutils` |\n| RHEL UBI9 after `dnf swap coreutils-single coreutils` | regular binary | `/usr/bin/sleep` |\n\nThe condition never becomes true, so the test always times out.\n\nReproducer, tested in `python:3-alpine` and `registry.access.redhat.com/ubi9/ubi`:\n\n```python\nimport os, subprocess, time\nproc = subprocess.Popen([\"sleep\", \"10\"])\ntime.sleep(0.5)\nprint(os.readlink(f\"/proc/{proc.pid}/exe\"))\nproc.kill()\n```\n\n### Suggested fix\n\nThe helper only needs to know that the child has called `exec()`. The program name doesn't matter. Before `exec()`, the forked child's `/proc/{pid}/exe` is the parent's Python executable, so wait until it differs from the parent's:\n\n```diff\n-def _wait_for_process_exec(proc, name, timeout):\n+def _wait_for_process_exec(proc, timeout):\n # Wait until a child process calls exec() to replace the forked process\n- # executable. Raise AssertionError on timeout.\n+ # executable. Don't check the executable name: it can be a multicall\n+ # binary such as /bin/busybox. Raise AssertionError on timeout.\n+ parent_exe = os.readlink(\"/proc/self/exe\")\n for _ in sleeping_retry(timeout, max_delay=0.1):\n exe = os.readlink(f\"/proc/{proc.pid}/exe\")\n- if os.path.basename(exe) == name:\n+ if exe != parent_exe:\n break\n```\n\n```diff\n- _wait_for_process_exec(proc, \"sleep\", SHORT_TIMEOUT)\n+ _wait_for_process_exec(proc, SHORT_TIMEOUT)\n```\n\nI tested this check with the reproducer on Alpine (BusyBox) and on UBI9 with both `coreutils-single` and `coreutils`. It detects the `exec()` in all three cases, while the current name check fails on Alpine and on UBI9 with `coreutils-single`.\n\n### CPython versions tested on:\n\n3.15.2, CPython main branch\n\n### Operating systems tested on:\n\nLinux (Alpine 3.24 buildbots, RHEL UBI9 container)\n\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-160901\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/thomgree","@type":"Person","name":"thomgree"},"datePublished":"2026-10-29T10:57:33Z","url":"https://github.com/python/cpython/issues/160881"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6764ce9a-417f-19e2-27ac-e9c07486d792 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 832C:23DB5F:1058B76:14832B3:6B023F39 |
| html-safe-nonce | 2822816220b3c9868137df60dcc65793233f94de292ccf98907098c42bda1d08 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzJDOjIzREI1RjoxMDU4Qjc2OjE0ODMyQjM6NkIwMjNGMzkiLCJ2aXNpdG9yX2lkIjoiMjM1MDY2NTE3ODA0MDkwOTYyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c0e29b4a7b7bbc441cb60d2a7c4dc0e6ce3cabee9ef9a5c85a10ab3ac438f33a |
| hovercard-subject-tag | issue:6098178744 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/160881/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c5fb05ca8642d95cfe0b611e5efe0caa75eab246869df7a703945c5438249173/python/cpython/issues/160881 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c5fb05ca8642d95cfe0b611e5efe0caa75eab246869df7a703945c5438249173/python/cpython/issues/160881 |
| og:image:alt | Bug report Bug description: The fix for gh-159534 (GH-160028, backported to 3.15 in GH-160080) makes test_is_python_process_non_python_subprocess fail every time on systems where sleep is provided ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | thomgree |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width