-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
libstd: use block buffering when stdout is not a TTY #60904
Conversation
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I'm not really sure how to fix the test cases other than adding explicit flushes as we can't lock |
It seems like adding explicit flushes is the expected necessary change after this PR. |
ping from triage @Arcterus any updates on this? |
Sorry, I’ve been dealing with some other stuff for the past couple weeks. I was trying to add the ability to switch buffering strategies the last time I was working on it, so I’ll try to get (at least) a preliminary implementation up this week. |
To enable switching blocking strategies, it'd probably be easiest to move from an enum to a single type that just has a bool inside tracking if it should flush on linebreaks or not. |
ping from triage @Arcterus |
It's still open. Did you forget to close it? |
@nico-abram yep 😄 |
This PR is meant to resolve #60673.
At the moment, there are a couple issues. I am unfamiliar with several of the platforms in
libstd::io::sys
, so I don't actually know if they have methods to determine ifstdout
is a TTY (or some equivalent).Additionally, the original issue mentioned buffering for
stderr
in addition tostdout
, which I have not implemented at the moment (although doing so is pretty straightforward). I also have not added methods to manually switch between block buffering and line buffering. If either of these are desired, let me know and I'll try to add them.I noticed that
run-pass/command-pre-exec.rs
seems to fail with this change because (AFAICT) theprintln!()
inCommand::pre_exec()
doesn't get flushed, so the contents ofstdout
are missing ahello
. I haven't modified the test yet because I am unsure if we should just tell users to flushstdout
(in which case I'll change the test), or if we should special case functions that can exit inlibstd
, or something else.run-pass/issues/issue-30490.rs
fails for a similar reason (doesn't flush beforeexec
).