From 4cf86c725e33c67743655bf0d639b3c7e5ca42cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Mon, 7 Sep 2020 15:50:48 +0200 Subject: [PATCH] detect EOL on stdin and no longer try to read commands. This can be locally tested with CTRL+D on basic mode. RUST_LOG=trace might help --- server-cli/src/main.rs | 5 +---- server-cli/src/tui_runner.rs | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 526c1be55d..64cb986618 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -119,10 +119,7 @@ fn main() -> io::Result<()> { break; }, }, - Err(e) => match e { - mpsc::TryRecvError::Empty => {}, - mpsc::TryRecvError::Disconnected => panic!(), - }, + Err(mpsc::TryRecvError::Empty) | Err(mpsc::TryRecvError::Disconnected) => {}, }; // Wait for the next tick. diff --git a/server-cli/src/tui_runner.rs b/server-cli/src/tui_runner.rs index 853f30a7cd..82aa5f58f0 100644 --- a/server-cli/src/tui_runner.rs +++ b/server-cli/src/tui_runner.rs @@ -118,10 +118,24 @@ impl Tui { while running.load(Ordering::Relaxed) { let mut line = String::new(); - io::stdin().read_line(&mut line).unwrap(); - debug!(?line, "basic mode: command entered"); - - parse_command(&line, &mut msg_s); + match io::stdin().read_line(&mut line) { + Err(e) => { + error!( + ?e, + "couldn't read from stdin, cli commands are disabled now!" + ); + break; + }, + Ok(0) => { + //Docker seem to send EOL all the time + warn!("EOL recieved, cli commands are disabled now!"); + break; + }, + Ok(_) => { + debug!(?line, "basic mode: command entered"); + parse_command(&line, &mut msg_s); + }, + } } }); } else {