cat: refactor stdio handling - #12210
Open
xtqqczze wants to merge 1 commit into
Open
Conversation
|
GNU testsuite comparison: |
xtqqczze
force-pushed
the
dd-stdin-raw
branch
3 times, most recently
from
May 10, 2026 01:47
c2a52d4 to
07699da
Compare
3 tasks
This comment was marked as outdated.
This comment was marked as outdated.
xtqqczze
force-pushed
the
dd-stdin-raw
branch
8 times, most recently
from
May 10, 2026 19:36
2736ee9 to
e95946e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Merging this PR will not alter performance
Comparing Footnotes
|
xtqqczze
force-pushed
the
dd-stdin-raw
branch
2 times, most recently
from
May 13, 2026 13:15
42e5ae2 to
a5a2281
Compare
xtqqczze
commented
May 13, 2026
| pub fn stdout_raw() -> StdoutRaw { | ||
| // SAFETY: We ensure that the file descriptor is never closed by | ||
| // wrapping the `File` in `ManuallyDrop`. | ||
| let fd = unsafe { rustix::stdio::take_stdout() }; |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| let fd = unsafe { rustix::stdio::take_stdout() }; | |
| let fd = unsafe { OwnedFd::from_raw_fd(libc::STDOUT_FILENO as RawFd) } |
We could avoid the rustix dependency here if so desired.
xtqqczze
marked this pull request as ready for review
May 13, 2026 15:46
xtqqczze
marked this pull request as draft
May 21, 2026 17:49
xtqqczze
marked this pull request as ready for review
May 24, 2026 13:44
xtqqczze
force-pushed
the
dd-stdin-raw
branch
5 times, most recently
from
September 5, 2026 07:47
b6d885e to
657641d
Compare
Contributor
Author
xtqqczze
force-pushed
the
dd-stdin-raw
branch
from
September 5, 2026 09:22
657641d to
02064e3
Compare
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.
Introduce safe wrappers for raw stdio backed by
ManuallyDrop<File>. TheManuallyDropprevents the file descriptor from being closed on drop, which could otherwise lead to undefined behavior.The wrapper only exposes
&File, so safe code cannot take ownership and accidentally drop the underlying descriptor.