diff options
author | Benjamin Nguyen <benjamin.van.nguyen@gmail.com> | 2023-07-01 18:17:35 +0700 |
---|---|---|
committer | Benjamin Nguyen <benjamin.van.nguyen@gmail.com> | 2023-07-01 18:17:35 +0700 |
commit | fc392b73a2461c83228712593fa1526b929fd94c (patch) | |
tree | 777ebe1456ba3df37413852ce61959e987e63a0f | |
parent | 2542e2867f5ae83c72893e43233f51c62e1c4f78 (diff) |
fix stdout deadlock
-rw-r--r-- | src/main.rs | 7 | ||||
-rw-r--r-- | src/progress.rs | 4 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 5c29e85..5f5e0b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,14 +64,11 @@ mod tty; mod utils; fn main() -> ExitCode { - let result = run(); - - tty::restore_tty(); - - if let Err(e) = result { + if let Err(e) = run() { eprintln!("{e}"); return ExitCode::FAILURE; } + ExitCode::SUCCESS } diff --git a/src/progress.rs b/src/progress.rs index 87395f9..a1cf32f 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -123,6 +123,7 @@ impl IndicatorHandle { .transpose()?; } } + Ok(()) } } @@ -144,7 +145,7 @@ impl<'a> Indicator<'a> { while let Ok(msg) = rx.recv() { if prx.recv_timeout(PRIORITY_MAIL_TIMEOUT).is_ok() { indicator.update_state(IndicatorState::Done)?; - break; + return Ok(()); } match msg { @@ -185,6 +186,7 @@ impl<'a> Indicator<'a> { let stdout = &mut self.stdout; stdout.execute(terminal::Clear(ClearType::CurrentLine))?; stdout.execute(cursor::RestorePosition)?; + stdout.execute(cursor::Show)?; }, _ => (), } |