From d4eb56d017486abd0af1427130197b87ad93b998 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 19 Jun 2022 01:46:13 +1000 Subject: [PATCH] Do not lock `stderr` in `UIThreadInner` which will prevent other thread from `eprintln!`. Signed-off-by: Jiahao XU --- src/helpers/ui_thread.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helpers/ui_thread.rs b/src/helpers/ui_thread.rs index 49908d90..0166cb1f 100644 --- a/src/helpers/ui_thread.rs +++ b/src/helpers/ui_thread.rs @@ -41,7 +41,6 @@ impl UIThreadInner { // access stdin let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); - let mut stderr = io::stderr().lock(); let mut input = String::with_capacity(16); loop { @@ -69,7 +68,9 @@ impl UIThreadInner { .expect("entry exits when confirming request") } Ok(UIRequest::PrintToStdout(output)) => stdout.write_all(&output).unwrap(), - Ok(UIRequest::PrintToStderr(output)) => stderr.write_all(&output).unwrap(), + Ok(UIRequest::PrintToStderr(output)) => { + io::stderr().write_all(&output).unwrap() + } Ok(UIRequest::FlushStdout) => stdout.flush().unwrap(), Err(_) => break, }