From eaaac9524fca0d03dac0879b546ad0a09feae58b Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Wed, 9 Sep 2020 19:27:27 +0200 Subject: [PATCH] fix(infra): do not block while reading from terminal, handle more than terminals --- src/main.rs | 4 ++++ src/os_input_output.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1e1bb932..b40f4484 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1496,6 +1496,8 @@ impl PtyBus { } if !bytes_is_empty { send_screen_instructions.send(ScreenInstruction::Render).unwrap(); + } else { + task::sleep(::std::time::Duration::from_millis(10)).await; } } } @@ -1518,6 +1520,8 @@ impl PtyBus { } if !bytes_is_empty { send_screen_instructions.send(ScreenInstruction::Render).unwrap(); + } else { + task::sleep(::std::time::Duration::from_millis(10)).await; } } } diff --git a/src/os_input_output.rs b/src/os_input_output.rs index a6e2159f..75c131c7 100644 --- a/src/os_input_output.rs +++ b/src/os_input_output.rs @@ -62,8 +62,8 @@ fn spawn_terminal () -> (RawFd, RawFd) { let pid_primary = fork_pty_res.master; let pid_secondary = match fork_pty_res.fork_result { ForkResult::Parent { child } => { - fcntl(pid_primary, FcntlArg::F_SETFL(OFlag::empty())).expect("could not fcntl"); - // fcntl(pid_primary, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("could not fcntl"); + // fcntl(pid_primary, FcntlArg::F_SETFL(OFlag::empty())).expect("could not fcntl"); + fcntl(pid_primary, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("could not fcntl"); child }, ForkResult::Child => {