fix(infra): do not block while reading from terminal, handle more than <cores> terminals

This commit is contained in:
Aram Drevekenin 2020-09-09 19:27:27 +02:00
parent 78cea539e6
commit eaaac9524f
2 changed files with 6 additions and 2 deletions

View file

@ -1496,6 +1496,8 @@ impl PtyBus {
} }
if !bytes_is_empty { if !bytes_is_empty {
send_screen_instructions.send(ScreenInstruction::Render).unwrap(); 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 { if !bytes_is_empty {
send_screen_instructions.send(ScreenInstruction::Render).unwrap(); send_screen_instructions.send(ScreenInstruction::Render).unwrap();
} else {
task::sleep(::std::time::Duration::from_millis(10)).await;
} }
} }
} }

View file

@ -62,8 +62,8 @@ fn spawn_terminal () -> (RawFd, RawFd) {
let pid_primary = fork_pty_res.master; let pid_primary = fork_pty_res.master;
let pid_secondary = match fork_pty_res.fork_result { let pid_secondary = match fork_pty_res.fork_result {
ForkResult::Parent { child } => { ForkResult::Parent { child } => {
fcntl(pid_primary, FcntlArg::F_SETFL(OFlag::empty())).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"); fcntl(pid_primary, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("could not fcntl");
child child
}, },
ForkResult::Child => { ForkResult::Child => {