-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add buffering to stdout #115652
Add buffering to stdout #115652
Conversation
I believe we won't need to; the buffer already flushed in `io::cleanup()` which is called on panic.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
The first three commits LGTM. The remainder will need an FCP to change behavior. |
This touches on two topics A) Is it ok to hand out file borrowed descriptors that violate the locks? #114140 B) Blockbuffering for stdout. #60673 and #78515 (comment) |
Changing the block buffering behaviour for stdout should be done in two steps:
I am personally not convinced (yet?) we should actually do step 2, but we all seem to be in favour of at least taking step 1. Step 2 can be a separate discussion. For step 1, we'd first need to see a proposal for an API for this. Several ideas have come up in the past, including adding a new 'switchable buffer/writer' type to See also #78515 (comment) I personally think that adding a block buffering mode to |
☔ The latest upstream changes (presumably #120365) made this pull request unmergeable. Please resolve the merge conflicts. |
r? libs-api |
Closing this because of #115652 (comment). Feel free to propose an API for step 1 to get things moving. Thanks! |
This PR includes implementing
IsTerminal
for the rawsys::stdio
structs, so we can check terminal status without constructing anStdout
object.Then
Stdout
switches from wrapping aLineWriter
to aStdoutWriter
, which wraps either aLineWriter
orBufWriter
depending on whether or not stdout is pointing to a terminal. This means standard output will no longer be line-buffered when outputting to a non-terminal.We could also make stdout wrap a
dyn Write
instead of theStdoutWriter
enum, which would make it simpler but I figured we don't want dynamic dispatch for every write to stdout.