fix(cron): prevent EBADF crash in cron scripts when parent stdin is closed - #40096
Closed
parthchandak02 wants to merge 1 commit into
Closed
fix(cron): prevent EBADF crash in cron scripts when parent stdin is closed#40096parthchandak02 wants to merge 1 commit into
parthchandak02 wants to merge 1 commit into
Conversation
…losed On macOS, long-running Hermes processes may close fd 0 (stdin) during the tool loop. When the child Python process starts, init_sys_streams calls fstat(0), which fails with EBADF -> "Fatal Python error: can't initialize sys standard streams". Pass stdin=subprocess.DEVNULL so fd 0 is always valid in the child. This is the same pattern already used in gateway/shutdown_forensics.py and tools/process_registry.py (commit 214b953). See CPython issue #10806 / loky #420.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
On macOS, long-running Hermes processes may close fd 0 (stdin) during the tool loop. When
subprocess.runlaunches a child Python process,init_sys_streamscallsfstat(0), which fails with EBADF →"Fatal Python error: can't initialize sys standard streams".This adds
stdin=subprocess.DEVNULLto_run_job_script()so fd 0 is always valid in the child. The same pattern is already used ingateway/shutdown_forensics.pyandtools/process_registry.py(commit 214b953).Related Issue
No existing issue — discovered locally on macOS 15.5. Root cause is CPython issue #10806 / loky #420.
Type of Change
Changes Made
cron/scheduler.py: Addedstdin=subprocess.DEVNULLtosubprocess.run()in_run_job_script()tests/cron/test_cron_script.py: Addedtest_script_survives_closed_parent_stdinregression testHow to Test
python -m pytest tests/cron/ -q— all tests pass_run_job_scriptand verifies the child runs successfullyChecklist
Code
fix(cron): prevent EBADF crash...)python -m pytest tests/cron/ -qand all 389 tests passDocumentation & Housekeeping
stdin=DEVNULLparam is harmless on other platformsScreenshots / Logs
Test output: