• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // run-pass
2 #![allow(unused_mut)]
3 // ignore-emscripten no processes
4 // ignore-sgx no processes
5 
6 use std::env;
7 use std::io::prelude::*;
8 use std::io;
9 use std::process::{Command, Stdio};
10 
main()11 fn main() {
12     let args: Vec<String> = env::args().collect();
13     if args.len() > 1 && args[1] == "child" {
14         return child()
15     }
16 
17     test();
18 }
19 
child()20 fn child() {
21     writeln!(&mut io::stdout(), "foo").unwrap();
22     writeln!(&mut io::stderr(), "bar").unwrap();
23     let mut stdin = io::stdin();
24     let mut s = String::new();
25     stdin.lock().read_line(&mut s).unwrap();
26     assert_eq!(s.len(), 0);
27 }
28 
test()29 fn test() {
30     let args: Vec<String> = env::args().collect();
31     let mut p = Command::new(&args[0]).arg("child")
32                                      .stdin(Stdio::piped())
33                                      .stdout(Stdio::piped())
34                                      .stderr(Stdio::piped())
35                                      .spawn().unwrap();
36     assert!(p.wait().unwrap().success());
37 }
38