Write to child process' stdin in Rust?
问题 Rust's std::process::Command allows configuring the process' stdin via the stdin method, but it appears that that method only accepts existing files or pipes. Given a slice of bytes, how would you go about writing it to the stdin of a Command ? 回答1: You can create a stdin pipe and write the bytes on it. As Command::output immediately closes the stdin, you'll have to use Command::spawn . Command::spawn inherits stdin by default. You'll have to use Command::stdin to change the behavior. Here is