use pwner::Spawner;
use std::io::{Read, Write};
fn main() {
let mut child = std::process::Command::new("cat")
.spawn_owned()
.expect("Couldn't start the child process");
let mut buffer = [0_u8; 1024];
while let Ok(bytes @ 1..=1024) = std::io::stdin().read(&mut buffer) {
child
.write_all(&buffer[..bytes])
.expect("Could not write to child");
if let Ok(bytes) = child.read(&mut buffer) {
if bytes == 0 {
println!("::");
} else if let Ok(string) = std::str::from_utf8(&buffer[..bytes - 1]) {
println!(":: {}", string);
}
}
}
}