Skip to content

Commit

Permalink
Fix CPU pegging when stdin stream has closed
Browse files Browse the repository at this point in the history
  • Loading branch information
chipsenkbeil committed Aug 3, 2021
1 parent a7dd0eb commit de69b41
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/subcommand/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,18 @@ fn spawn_stdin_reader() -> mpsc::Receiver<String> {

loop {
let mut line = String::new();
if stdin.read_line(&mut line).is_ok() {
if let Err(x) = tx.blocking_send(line) {
error!(
"Failed to pass along stdin to be sent to remote process: {}",
x
);
match stdin.read_line(&mut line) {
Ok(0) | Err(_) => break,
Ok(_) => {
if let Err(x) = tx.blocking_send(line) {
error!(
"Failed to pass along stdin to be sent to remote process: {}",
x
);
}
// std::thread::sleep(std::time::Duration::from_millis(1));
std::thread::yield_now();
}
} else {
break;
}
}
});
Expand Down

0 comments on commit de69b41

Please sign in to comment.