Skip to content

Instantly share code, notes, and snippets.

@hunterboerner
Created April 5, 2015 15:16
Show Gist options
  • Save hunterboerner/5ed2930c63046e98703b to your computer and use it in GitHub Desktop.
Save hunterboerner/5ed2930c63046e98703b to your computer and use it in GitHub Desktop.
Spawn a command in Rust with separate STDIO and then print it out to the main thread's STDOUT (or whatever buffer you want).
let process = Command::new("randomstrings").stdin(Stdio::piped()).stdout(Stdio::piped()).spawn().unwrap();
let mut thing = process.stdout.unwrap();
loop {
let something: &mut [u8] = &mut [0];
thing.read(something);
print!("{}", std::str::from_utf8(something).unwrap())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment