GeezerVison is showing github.com — Fix os.closerange and immediate process exit by youknowdot · Pull Request #9006 · RustPython/RustPython
Conversation
Summary
Split the portable descriptor/termination fixes out of #8954 for the current Python 3.14 main branch.
- Close raw CRT descriptor numbers in
os.closerange, ignoring close errors as required. A range can contain already-closed descriptors and cannot safely be represented by OwnedFd values.
- Use the host CRT
_exit for Python os._exit, failed child exec, the fatal-signal fallback, and faulthandler's exit=True watchdog. Ordinary interpreter shutdown and the non-host fallback are unchanged.
The diff is four Rust files, with no canonical test, workflow, dependency, or profile changes.
Validation
Independently tested on the main-based commit, rather than reusing the mega-PR results:
- Normal commit hooks and strict workspace/C-API Clippy passed.
- Workspace tests: 1,352 passed, 18 ignored; separate C-API tests: 116 passed, 4 ignored.
- C-API-enabled dev and CI production-feature release builds passed, with the Python 3.14 runtime and this checkout's test-source paths verified.
- Both existing
test_os closerange cases, full FileTests, test_atexit, and three canonical child-failure cases passed. Existing platform/implementation skips are unchanged.
- A child-scoped native C fixture verified that normal exit runs C atexit handlers and flushes buffered C stdio, while
os._exit(0/37) and watchdog exit=True do neither. Failed child exec avoids inherited C exit handlers while the parent still cleans up normally. This passed in dev and release builds.
Full local test_os was not run because the sandbox denies its asyncio AF_UNIX socketpair. The unchanged hosted tests remain enabled. Local execution was Linux only; cross-platform CI is pending.
AI assistance
Codex assisted with implementation, extraction, source review, and validation. Both commits retain their Assisted-by disclosure trailers.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Close raw descriptor numbers through the host CRT layer rather than constructing OwnedFd values for possibly closed descriptors. Preserve the half-open range, ignored close errors and Windows invalid-parameter handling.
Assisted-by: Codex:model-version-unavailable
Python os._exit, failed child exec and fatal/watchdog exits must bypass C exit handlers. Call the host CRT _exit on Unix, Windows and WASI while retaining the existing non-host fallback. Normal interpreter termination is unchanged.
Assisted-by: Codex:model-version-unavailable
coderabbitai
Bot
commented
Oct 8, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Note Currently processing new changes in this PR. This may take a few minutes, please wait...
⚙️ Run configuration
- Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
40e2aada-881d-477c-a426-0bab0dcd0d13
📥 Commits
Reviewing files that changed from the base of the PR and between bb9ef5d and 1259e5c.
📒 Files selected for processing (4)
crates/host_env/src/crt_fd.rs
crates/host_env/src/crt_fd_unsupported.rs
crates/host_env/src/os.rs
crates/vm/src/stdlib/os.rs
________________________________________________________________________________________________________________________
< Don't assume it - prove it. Prove your assumptions in the actual environment - with real data and boundary conditions. >
------------------------------------------------------------------------------------------------------------------------
\
\ \
\ /\
( )
.( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will not alter performance
✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1
Comparing youknowdot:fix-portable-os-termination (1259e5c) with main (bb9ef5d)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|