Hi, I'm trying to implement timeout of reading STDOUT of a Popen process. I have code like that:
// self.process is a subprocess::Popen self.process .stdin .as_ref() .unwrap() .write("Long text".as_bytes()); self.process.stdin.as_ref().unwrap().write("\n".as_bytes()); let mut contents = String::new(); let mut buf_reader = BufReader::with_capacity(512 * 1024, self.process.stdout.as_ref().unwrap()); buf_reader.read_line(&mut contents); // Sometime my code hangs here.
I found timeout-readwrite but it doesn't work with Rust 2018.
Could you give me a few advices how can I do a timeout for Read here?