GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix os.closerange and immediate process exit by youknowdot · Pull Request #9006 · RustPython/RustPython

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions
youknowdot added 2 commits October 8, 2026 20:03
@youknowdot
Ignore invalid descriptors in os.closerange
d5bd4ad
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
@youknowdot
Use immediate exit for host process termination
1259e5c
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

coderabbitai Bot commented Oct 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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)
  • Create a new PR
  • 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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codspeed

codspeed Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:fix-portable-os-termination (1259e5c) with main (bb9ef5d)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowdot youknowdot mentioned this pull request Oct 8, 2026
Return EBADF for negative stat file descriptors #9008
Merged
youknowone
youknowone approved these changes Oct 8, 2026
View reviewed changes
@youknowone
youknowone marked this pull request as ready for review October 8, 2026 15:12
@youknowone
youknowone merged commit 54e47cd into RustPython:main Oct 8, 2026
30 of 31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@youknowone youknowone youknowone approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@youknowdot @youknowone
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.