TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Subprocess: Don't close all file descriptors by default (close_fds=False)

35 pointsby luu5 months ago

9 comments

htfy965 months ago
Meanwhile VSCode&#x27;s terminal still leaks Electron fds: <a href="https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;node-pty&#x2F;issues&#x2F;657">https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;node-pty&#x2F;issues&#x2F;657</a><p>I get this proposal&#x27;s rationale, but it seems that it would implicitly make fd leaks more prone in python programs
oseityphelysiol5 months ago
Of all the quirks with process spawning in posix keeping file descriptors open is the most problematic one I encountered. This bit into my ass while implementing a C library to have proper process spawning and stdio handling in LUA. I really wish file descriptors were non inheritable by default.
评论 #42517110 未加载
teddyh5 months ago
The counter-arguments presented seem persuasive. This was originally submitted in 2020, and closed in 2022. Why is it relevant or interesting today?
评论 #42517652 未加载
williamjackson5 months ago
<a href="https:&#x2F;&#x2F;github.com&#x2F;python&#x2F;cpython&#x2F;issues&#x2F;86904">https:&#x2F;&#x2F;github.com&#x2F;python&#x2F;cpython&#x2F;issues&#x2F;86904</a>
评论 #42517123 未加载
nasretdinov5 months ago
Go goes slightly further and opens all descriptors with O_CLOEXEC by default, so if you ever execute an external command you have to go out of your way to preserve any descriptors, which is really nice in my opinion
评论 #42517435 未加载
mmastrac5 months ago
FDs really should have been opt-in for inheritability from the start, with the possible exception of stdio. Inheritability being an fcntl is definitely one of the worst bits -- if the APIs for fork()&#x2F;etc were designed today it would probably take a list of FDs that would be dup2&#x27;d in the new child process.
评论 #42517328 未加载
评论 #42517426 未加载
评论 #42519074 未加载
loeg5 months ago
(2020), or perhaps 2021.
Pesthuf5 months ago
&gt; On macOS, posix_spawn() is even a syscall.<p>First time I hear about this, interesting. I wonder what the performance benefits are like.
zitterbewegung5 months ago
Dang: Link should be <a href="https:&#x2F;&#x2F;github.com&#x2F;python&#x2F;cpython&#x2F;issues&#x2F;86904">https:&#x2F;&#x2F;github.com&#x2F;python&#x2F;cpython&#x2F;issues&#x2F;86904</a>