-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed standard file descriptors don't generate errors anymore on Unix #88825
Comments
I wonder why bash even lets you close the output descriptors when spawning a child, that seems like a direct violation of posix requirements that spawned processes must have fds 0-2 open at program startup. https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdout.html |
I think this falls in this drawback noted in #75295:
It’s intentional in this test case, but the point of that test is ensuring Mercurial reports an error for unintentional closing instead of silently losing output. |
Some more background on why the test was introduced to Mercurial in the first place: https://www.mercurial-scm.org/repo/hg/rev/a04c03b0678e |
This is actually valid in POSIX shell: https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_07_05. This may constitute a contradiction, but there appears to be no explicit mention of standard fds. |
With changes from #75295 the standard file descriptors are now reopened to Generally the fact that they are reopened and inherited is expected outcome. Additionally, I think it might be a bad idea to rely on being able to detect I will also note that Command in the Rust standard library works incorrectly |
Maybe CommandExt::pre_exec can be used to work around this by closing the file descriptors after the fork. |
This is actually basically the same issue as #47271, just with a more recent development. |
It's not possible to detect closed file descriptors from Rust since the |
The 2017 version resolves this contradiction
|
I've found that #75295 introduced a regression in the "Rust first then fallback to Python" version of the Mercurial test suite.
I was testing if going from
1.41.1
(previous Debian stable version) to1.48.0
broke anything, and it appears it did. This test checks that closed file descriptors raise an acceptable error, and this does not happen anymore. Here is the fallback code forrhg
, running the Python version ofhg
as a subprocess.Here is the (somewhat convoluted) reproduction, which requires
python
be a valid Python 3 interpreter that I used withcargo bisect-rust
(thanks @SimonSapin for the pointer on that tool btw):I'm not 100% sure what to think of it yet, but my gut feeling is that eating errors is bad; I'm reporting this now since it's fresh in my mind.
The text was updated successfully, but these errors were encountered: