Repository navigation
Conversation
oech3
reviewed
Oct 25, 2026
| // A closed stdin is reopened as /dev/null before `uumain` runs, so | ||
| // reading it would succeed silently instead of failing with EBADF. | ||
| #[cfg(unix)] | ||
| if uucore::signals::stdin_was_closed() { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
oech3
reviewed
Oct 25, 2026
|
|
||
| // A closed stdin is reopened as /dev/null before `uumain` runs, so | ||
| // reading it would succeed silently instead of failing with EBADF. | ||
| #[cfg(unix)] |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
oech3
reviewed
Oct 25, 2026
Comment on lines
+155
to
+156
| // A closed stdin is reopened as /dev/null before `uumain` runs, so | ||
| // reading it would succeed silently instead of failing with EBADF. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
oech3
reviewed
Oct 25, 2026
| let input = rustix::stdio::stdin(); | ||
| #[cfg(not(any(unix, target_os = "wasi")))] | ||
| let mut input = io::stdin(); | ||
|
|
fixfon
force-pushed
the
fix/10154-tee-closed-stdin
branch
from
October 25, 2026 13:46
e8b4b41 to
62aa0f5
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refs #10154
tee <&-exited 0 without a word. Rust's runtime reopens a closed stdin as/dev/nullbeforeuumainruns, soteeread EOF and finished normally.copy_unbufferednow checksuucore::signals::stdin_was_closed()before the first read and reports the existingread error: Bad file descriptormessage, exit code 1. The output files are opened and truncated before that point, like they are for any other read error. The check is the same one #15253 added tocat, and it iscfg(unix)only.I added
test_closed_stdintotests/by-util/test_tee.rs. It startstee filethroughsh -c 'exec <&-; ...', expects exit code 1, the error on stderr, no stdout and an emptyfile. It fails without the fix (tee exits 0) and passes with it.cargo fmt --all -- --checkandclippy -p uu_tee --all-targets -D warningsare clean. The rest oftest_teepasses excepttest_tee_output_not_buffered, which fails the same way on main on my machine; I did not dig into why. Tested on macOS only. The issue lists other tools too, this PR only touchestee.