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
This commit is contained in:
Marcel Märtens 2020-09-07 15:50:48 +02:00
parent a531aeca13
commit 4cf86c725e
2 changed files with 19 additions and 8 deletions

View File

@ -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.

View File

@ -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 {