From 7807f565ec42a64e9b8037d8b238a8d0a47893d8 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 27 Feb 2020 16:40:03 +0200 Subject: [PATCH] Clear input thread channel on restore() The channel may contain Kill commands that will cause the new thread to exit immediately. --- src/state.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/state.rs b/src/state.rs index 18de921dc..6bc04dfdd 100644 --- a/src/state.rs +++ b/src/state.rs @@ -52,6 +52,10 @@ struct InputHandler { impl InputHandler { fn restore(&self, tx: Sender) { + /* Clear channel without blocking. switch_to_main_screen() issues a kill when + * returning from a fork and there's no input thread, so the newly created thread will + * receive it and die. */ + let _ = self.rx.try_iter().count(); let rx = self.rx.clone(); thread::Builder::new() .name("input-thread".to_string())