• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![deny(warnings)]
2 
3 /// This little test binary reads stdin and write what it reads to both
4 /// stdout and stderr. It depends on os_pipe's parent_* functions, and
5 /// we use it to test them.
6 use std::env::args_os;
7 use std::ffi::OsString;
8 use std::process::Command;
9 
main()10 fn main() {
11     let stdin = os_pipe::dup_stdin().unwrap();
12     let stdout = os_pipe::dup_stdout().unwrap();
13     let stderr = os_pipe::dup_stderr().unwrap();
14 
15     let args: Vec<OsString> = args_os().collect();
16     let mut child = Command::new(&args[1]);
17     child.args(&args[2..]);
18 
19     // Swap stdout and stderr in the child. Set stdin too, just for testing,
20     // though this should be the same as the default behavior.
21     child.stdin(stdin);
22     child.stdout(stderr);
23     child.stderr(stdout);
24 
25     // Run the child. This method is kind of confusingly named...
26     child.status().unwrap();
27 }
28