René's URL Explorer Experiment


Title: Preserve closed standard streams before Rust startup by youknowone · Pull Request #9939 · RustPython/RustPython · GitHub

Open Graph Title: Preserve closed standard streams before Rust startup by youknowone · Pull Request #9939 · RustPython/RustPython

X Title: Preserve closed standard streams before Rust startup by youknowone · Pull Request #9939 · RustPython/RustPython

Description: Summary Preserve missing standard streams in the Linux/macOS executable without undoing Rust's descriptor sanitization. Rust opens /dev/null for missing descriptors 0–2 before calling main. By the time the VM checks them, they look valid and Python incorrectly exposes streams instead of None. Capture only EBADF observations in an executable-local pre-runtime initializer. Retry EINTR, preserve errno, use no allocation or Rust I/O, and leave every descriptor unchanged. Apply that snapshot through the existing initialization hook, after CLI option parsing and before Python stream creation. Keep normal embedding behavior and clear the startup snapshot when initializing a subinterpreter. A genuinely open /dev/null is still a usable stream. Enable the four existing closed-stdio tests on Linux/macOS. Other platforms retain their existing expected-failure status; no assertions or new tests are added. The initializer is target-ABI code (.init_array / __mod_init_func), deliberately confined to the executable rather than a VM or host library. It observes descriptors before Rust initialization, not before arbitrary native-library constructors or secure-exec normalization. Windows CRT startup is not changed. This does not alter #9877's host capability policy. Validation Linux x86_64, Rust 1.100, CPython 3.15.2 comparison: Workspace Rust/doc tests excluding wasm, venvlauncher and C-API: 1,619 passed, 21 ignored. cargo check configurations with stdio disabled and with host_env disabled pass. Workspace all-targets Clippy passes; only the existing wasi-host manifest warning remains. Normal commit hooks pass. Eight alternating ten-process development-build startup batches: median 0.1388s baseline / 0.1431s candidate. Individual batch means ranged roughly 0.110–0.176s, so this noisy smoke test does not establish a performance improvement or a statistically meaningful regression. Complete test_cmd_line, test_cmd_line_script, test_repl: 150 tests, 26 skips, success; unrelated expected failures retained. All eight closed-descriptor combinations and seven explicitly open /dev/null combinations match the reference. Reopening fd 0 after initialization leaves the main interpreter's Python stdin as None but lets a new subinterpreter use the reopened descriptor, matching CPython. A separate embedding executable linked against the library retains its previous behavior, proving the startup initializer is not injected into embeddings. An initial test run failed test_dump_path_config because the test launcher itself exported RUSTPYTHONPATH, masking the intentional bad PYTHONHOME; the complete clean-environment run passes. No test suppression was used. macOS/Windows execution, C-API tests, and release performance have not been run locally. C-API work remains deferred. AI assistance: OpenAI Codex performed implementation and validation with an independent source-level review. The exact model identifier is unavailable; the commit records Assisted-by: Codex:unspecified rather than guessing.

Open Graph Description: Summary Preserve missing standard streams in the Linux/macOS executable without undoing Rust's descriptor sanitization. Rust opens /dev/null for missing descriptors 0–2 before calling main. By ...

X Description: Summary Preserve missing standard streams in the Linux/macOS executable without undoing Rust's descriptor sanitization. Rust opens /dev/null for missing descriptors 0–2 before calling main....

Opengraph URL: https://github.com/RustPython/RustPython/pull/9939

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:492ae865-55fe-1fcc-ea15-aa7344358d01
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBA4E:36A3E:2E3F3A8:3DB50ED:6B01DE5D
html-safe-noncea8c26b23fe0111dcd93c3fc7530304d30e2738acf99aeeda48fead8e9faf321c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTRFOjM2QTNFOjJFM0YzQTg6M0RCNTBFRDo2QjAxREU1RCIsInZpc2l0b3JfaWQiOiI1NDgyMTUyMTA5MTQyMDkzNzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacaf8135a733a06a0ccafaf27c12dc6a68bbdebde6a98bbc32715281a1825dbbdf
hovercard-subject-tagpull_request:5374202450
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9939/files
twitter:imagehttps://avatars.githubusercontent.com/u/69878?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/69878?s=400&v=4
og:image:altSummary Preserve missing standard streams in the Linux/macOS executable without undoing Rust's descriptor sanitization. Rust opens /dev/null for missing descriptors 0–2 before calling main. By ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/9939/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9939%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9939%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/9939/files
Reloadhttps://github.com/RustPython/RustPython/pull/9939/files
Reloadhttps://github.com/RustPython/RustPython/pull/9939/files
RustPythonhttps://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Codehttps://github.com/RustPython/RustPython
Issues195 (195)https://github.com/RustPython/RustPython/issues
Pull requests133 (133)https://github.com/RustPython/RustPython/pulls
Discussionshttps://github.com/RustPython/RustPython/discussions
Actionshttps://github.com/RustPython/RustPython/actions
Projectshttps://github.com/RustPython/RustPython/projects
Wikihttps://github.com/RustPython/RustPython/wiki
Security and qualityhttps://github.com/RustPython/RustPython/security
Insightshttps://github.com/RustPython/RustPython/insights
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
youknowonehttps://github.com/youknowone
mainhttps://github.com/RustPython/RustPython/tree/main
dot/closed-stdio-3152https://github.com/RustPython/RustPython/tree/dot/closed-stdio-3152
Conversation 3 https://github.com/RustPython/RustPython/pull/9939
Commits 1 https://github.com/RustPython/RustPython/pull/9939/commits
Checks 31 https://github.com/RustPython/RustPython/pull/9939/checks
Files changed 6 https://github.com/RustPython/RustPython/pull/9939/files
Preserve closed standard streams before Rust startup https://github.com/RustPython/RustPython/pull/9939/files#top
Show all changes 1 commit https://github.com/RustPython/RustPython/pull/9939/files
7679b9f Preserve closed standard streams before Rust startup youknowone Nov 18, 2026 https://github.com/RustPython/RustPython/pull/9939/commits/7679b9fac1af2f0b4f60269cb865992cb72b2089
Clear filters https://github.com/RustPython/RustPython/pull/9939/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9939/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9939/files
Cargo.toml https://github.com/RustPython/RustPython/pull/9939/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542
test_cmd_line.py https://github.com/RustPython/RustPython/pull/9939/files#diff-128fff16ea63b541718887f5c714e0c1a357414fe1146b4893ef699e8853e3b0
interpreter.rs https://github.com/RustPython/RustPython/pull/9939/files#diff-2361f366cc46771907dbd3b09eb8b9c839e7f059710345f2265c1753862a1b20
mod.rs https://github.com/RustPython/RustPython/pull/9939/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
setting.rs https://github.com/RustPython/RustPython/pull/9939/files#diff-9fc754581ca0739d7d6441cd6c1ce8bdd83220b0e7f71517c33aaffb622390f5
main.rs https://github.com/RustPython/RustPython/pull/9939/files#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fc
Cargo.tomlhttps://github.com/RustPython/RustPython/pull/9939/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542
View file https://github.com/RustPython/RustPython/blob/7679b9fac1af2f0b4f60269cb865992cb72b2089/Cargo.toml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9939/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9939/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542
https://github.com/RustPython/RustPython/pull/9939/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542
Lib/test/test_cmd_line.pyhttps://github.com/RustPython/RustPython/pull/9939/files#diff-128fff16ea63b541718887f5c714e0c1a357414fe1146b4893ef699e8853e3b0
View file https://github.com/RustPython/RustPython/blob/7679b9fac1af2f0b4f60269cb865992cb72b2089/Lib/test/test_cmd_line.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9939/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9939/files#diff-128fff16ea63b541718887f5c714e0c1a357414fe1146b4893ef699e8853e3b0
https://github.com/RustPython/RustPython/pull/9939/files#diff-128fff16ea63b541718887f5c714e0c1a357414fe1146b4893ef699e8853e3b0
crates/vm/src/vm/interpreter.rshttps://github.com/RustPython/RustPython/pull/9939/files#diff-2361f366cc46771907dbd3b09eb8b9c839e7f059710345f2265c1753862a1b20
View file https://github.com/RustPython/RustPython/blob/7679b9fac1af2f0b4f60269cb865992cb72b2089/crates/vm/src/vm/interpreter.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9939/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9939/files#diff-2361f366cc46771907dbd3b09eb8b9c839e7f059710345f2265c1753862a1b20
https://github.com/RustPython/RustPython/pull/9939/files#diff-2361f366cc46771907dbd3b09eb8b9c839e7f059710345f2265c1753862a1b20
crates/vm/src/vm/mod.rshttps://github.com/RustPython/RustPython/pull/9939/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
View file https://github.com/RustPython/RustPython/blob/7679b9fac1af2f0b4f60269cb865992cb72b2089/crates/vm/src/vm/mod.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9939/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9939/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
https://github.com/RustPython/RustPython/pull/9939/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
crates/vm/src/vm/setting.rshttps://github.com/RustPython/RustPython/pull/9939/files#diff-9fc754581ca0739d7d6441cd6c1ce8bdd83220b0e7f71517c33aaffb622390f5
View file https://github.com/RustPython/RustPython/blob/7679b9fac1af2f0b4f60269cb865992cb72b2089/crates/vm/src/vm/setting.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9939/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9939/files#diff-9fc754581ca0739d7d6441cd6c1ce8bdd83220b0e7f71517c33aaffb622390f5
https://github.com/RustPython/RustPython/pull/9939/files#diff-9fc754581ca0739d7d6441cd6c1ce8bdd83220b0e7f71517c33aaffb622390f5
https://github.com/RustPython/RustPython/pull/9939/files#diff-9fc754581ca0739d7d6441cd6c1ce8bdd83220b0e7f71517c33aaffb622390f5
https://github.com/RustPython/RustPython/pull/9939/files#diff-9fc754581ca0739d7d6441cd6c1ce8bdd83220b0e7f71517c33aaffb622390f5
src/main.rshttps://github.com/RustPython/RustPython/pull/9939/files#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fc
View file https://github.com/RustPython/RustPython/blob/7679b9fac1af2f0b4f60269cb865992cb72b2089/src/main.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9939/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9939/files#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fc
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9939/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.