-
Notifications
You must be signed in to change notification settings - Fork 14k
Work with stdbuf environment variables
#148986
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
Conversation
Check `_STDBUF_O` and `_STDBUF_E` environment variables for setting up stdout and stderr. This makes Rust programs compatible with coreutils's (and `uutils`'s) `stdbuf` program. It incidentally also solves uutils/coreutils#7967. This lays ground work for solving rust-lang#60673 because it lets the user of a Rust program decide the default buffering, offering the opportunity to change the current default, letting stdout buffer blockwise if it's not connected to a terminal, because the user can now override the behavior using [`stdbuf`](https://linux.die.net/man/1/stdbuf) if it's needed.
|
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use |
|
|
Based on #148274 because it makes some of the changes I need here, as well. |
|
Nominating for libs-api to decide whether we want to support this configuration interface. |
uh? ...what actually happens, here? |
|
I don't think this set of environment variables should be the first interface that Rust exposes to control stdio buffering. It's an undocumented, platform-specific interface (though this PR apparently generalizes it to all platforms) and would be insta-stable. Furthermore, the way it's implemented in this PR probably means (haven't tried it) that programs can choose their own buffering strategy by using |
|
Also see #78515 (comment) for the last time the team discussed this. |
|
I think a decision on the first steps should be made in an issue (or ACP) before the implementation PR. Tbh, I'd be minded to close this until such a decision is made but as it's been nominated for libs-api discussion. I'll defer to that. |
I think
Doesn't sound like a big problem in this case, as this is not something documented right now, but just a quality of implementation thing, which can be reverted within the stability guarantees of Rust.
This could be fixed if wanted, by looking at the environment variables earlier in the process, maybe before
I don't want this to be the only way to set it, but a first way. Adding APIs for Rust programs to control their own buffering would also be very nice, but is relatively independent from this. A PR adding such APIs is also made easier by merging this, because of
Seems to be about Rust programs controlling their own buffering, not setting the buffering from outside the Rust program. |
|
After a quick experiment and some digging about the error I got, I now know more than I ever wanted to about how GNU coreutils It turns out that the environment variables read by this PR are intended as internal implementation detail for a dynamic library that the |
|
@hanna-kruppe Thanks for the idea and testing it. I can confirm it also doesn't work on my machine. Hmm. If |
|
libs-api discussion is not needed if even the PR author thinks it's a bad idea now :D |
|
Closing for that reason. |
Check
_STDBUF_Oand_STDBUF_Eenvironment variables for setting up stdout and stderr. This makes Rust programs compatible with coreutils's (anduutils's)stdbufprogram. It incidentally also solves uutils/coreutils#7967.This lays ground work for solving #60673 because it lets the user of a Rust program decide the default buffering, offering the opportunity to change the current default, letting stdout buffer blockwise if it's not connected to a terminal, because the user can now override the behavior using
stdbufif it's needed.