Repository navigation
Conversation
Merging this PR will improve performance by ×23 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
|
Please don't fix closed stdout things. we auto-achieve this after std was updated. |
| }); | ||
|
|
||
| #[cfg(not(target_os = "fuchsia"))] | ||
| uucore::signals::preserve_closed_stdio_on_exec() |
There was a problem hiding this comment.
I don't know how test on the CI, but this approach raises EBADF before actual I?O happens e.g. cat >&- (input is terminal and you did not type anything yet). std itself's fix is absolutely needed.
5f15449 to
ad30cbf
Compare
|
Thanks for pointing this out. I dropped the --version workaround and narrowed the PR to env. Even on the latest Rust nightly, env can still give a child writable stdout after the caller closed it. I checked the timing too. With the fix, the child can read input and exit successfully without writing. If it does write, it gets an error at that point. That matches what I saw with GNU env. I’ve squashed and pushed the update. |
This comment was marked as outdated.
This comment was marked as outdated.
|
Does it mean #16929 + nightly , or nightly only? |
ad30cbf to
4b82351
Compare
Mark the Rust runtime's replacement descriptors close-on-exec so that the child inherits closed standard streams and handles its own I/O errors.
4b82351 to
57dbdea
Compare
When the caller closes stdout, Rust can reopen it before
envstarts. A child command can then write successfully and silently lose its output. Mark the runtime's replacement standard descriptors close-on-exec so the child inherits the same closed streams as its caller.The regression tests cover all three standard streams. With stdout closed, a shell can still read input and exit successfully if it never writes. If it does write, the shell gets the write error. This matches GNU env 9.12 on Linux, including when uutils is built with Rust 1.102 nightly.
All 130 env tests passed on Linux. Ten checksum cases in GNU 9.12's
misc/io-errors.shnow pass when launched through env, bringing the failure count for that script from 142 to 132.Closes #17129.