Skip to content
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

Document buffering behaviour fot Stdout(Lock) #137628

Open
bertptrs opened this issue Feb 25, 2025 · 1 comment
Open

Document buffering behaviour fot Stdout(Lock) #137628

bertptrs opened this issue Feb 25, 2025 · 1 comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@bertptrs
Copy link
Contributor

Location

Summary

The handles provided by std::io::stdout() are line-buffered, but there is nothing in the documentation suggesting this. The only mention of buffering for stdout in the documentation is the line

Each handle shares a global buffer of data to be written to the standard output stream. Access is also synchronized via a lock and explicit control over locking is available via the lock method.

I don't think this is very clear that stdout is buffered from this, nor that it uses line buffering.

Moreover, the comments for LineWriterShim suggest that this mechanism can be used to alternate between line buffering and block buffering for Stdout, which isn't mentioned in the documentation for Stdout at all.

I do not mean to relitigate whether or not it should be buffered (previous discussion in #23818) but I'd like to clarify how it is buffered, and how one should deal with it.

@bertptrs bertptrs added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Feb 25, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 25, 2025
@fmease fmease added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 25, 2025
@the8472
Copy link
Member

the8472 commented Feb 25, 2025

Looks like a duplicate of #106133

Additionally the behavior is not set in stone, there is some desire to change the buffering behavior: #60673

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants