expectrl: sleep() before interactive() causes freeze
The code below run as expected, printing the git diff help, then result StillAlive, then exiting.
fn main() {
let mut cmd = std::process::Command::new("git");
cmd.args(["diff"]);
cmd.current_dir("/tmp");
let mut session = expectrl::Session::spawn(cmd).expect("Can't spawn a session");
let mut opts = expectrl::interact::InteractOptions::terminal().unwrap();
let res = opts.interact(&mut session).unwrap();
println!("result {:?}", res);
}
This code freezes, printing nothing and not exiting:
fn main() {
let mut cmd = std::process::Command::new("git");
cmd.args(["diff"]);
cmd.current_dir("/tmp");
let mut session = expectrl::Session::spawn(cmd).expect("Can't spawn a session");
std::thread::sleep(std::time::Duration::from_millis(300));
let mut opts = expectrl::interact::InteractOptions::terminal().unwrap();
let res = opts.interact(&mut session).unwrap();
println!("result {:?}", res);
}
Hitting return causes the program to continue as before. It seems like the delay is causing expectrl to enter the interactive mode in a blocking way, but that’s not quite right because interactive mode should require ^] to exit, not just a return. Also, there’s no input command here awaiting a return.
The expected behavior would be that the output is exactly as before but delayed 300ms.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 15 (10 by maintainers)
Once again just for an update, I haven’t found a solution for this “bug” yet.
But it is 100% related to a core
ptylib.Only found a similar issue in a https://github.com/creack/pty/issues/101 which seems to be unresolved fully.
Froze! Waited more than 5m.
Will do…