当我尝试cmd.exe通过以下代码开始时:
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
}
Run Code Online (Sandbox Code Playgroud)
我想将输出重定向到管道,但它总是报告The process tried to write to a nonexistent pipe;当我删除时.stdout(Stdio::piped()),没有抛出错误。为什么会发生这种情况?