core: lock stdout before printing an error message to stderr

Adds a new eprintln_locked macro which locks STDOUT before logging
to STDERR. This patch also replaces instances of eprintln with
eprintln_locked to avoid interleaving lines.

Fixes #1941, Closes #1968
This commit is contained in:
Garrett Thornburg
2021-08-09 23:32:08 -06:00
committed by Andrew Gallant
parent 4993d29a16
commit 4782ebd5e0
3 changed files with 23 additions and 7 deletions

View File

@@ -47,7 +47,7 @@ type Result<T> = ::std::result::Result<T, Box<dyn error::Error>>;
fn main() {
if let Err(err) = Args::parse().and_then(try_main) {
eprintln!("{}", err);
eprintln_locked!("{}", err);
process::exit(2);
}
}