When I try to start cmd.exe by the following code:
use std::process::{Command, Stdio};
use std::io::{BufRead, Write, BufReader};
fn main() {
let mut child_cmd = Command::new("cmd.exe")
// seems it work well with `/bin/bash` in Linux
.stdin(Stdio::piped())
.stdout(Stdio::piped()) // Error emitted here.
.spawn()
.unwrap();
// do sth. else
}
I want to redirect the output to pipeline, but it always report The process tried to write to a nonexistent pipe; when I removed .stdout(Stdio::piped()), no errors thrown. Why does this happen?