Exit without flushing stdout and stderr #5542
Merged
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.
I noticed the calls to flush standard out and err before calling
std::process:exit()
and I believe they aren't necessary.Standard out is flushed when calling
std::process::exit()
:And standard error is unbuffered, and so doesn't need to be flushed.
I noticed this function was added in PR #1873, to fix issue #1871.
I checked out 4675070a, the commit before #1873 was merged, and wasn't able to reproduce the issue in #1871, whose repro steps are to run
cargo run --example 09_auto_version -- --version
and not see any version output.So I'm thinking it's likely that at some point, the rust stdlib changed to flush stdout before exiting.
Since
clap
has MSRV 1.74, I installed 1.74.0 and rancargo +1.74.0 run --example 09_auto_version -- --version
to make sure that things still worked with the oldest supported rust version.