1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 #![feature(io, process_capture)]
15 use std::io::prelude::*;
17 use std::process::{Command, Stdio};
20 let args: Vec<String> = env::args().collect();
21 if args.len() > 1 && args[1] == "child" {
29 writeln!(&mut io::stdout(), "foo").unwrap();
30 writeln!(&mut io::stderr(), "bar").unwrap();
31 let mut stdin = io::stdin();
32 let mut s = String::new();
33 stdin.lock().read_line(&mut s).unwrap();
34 assert_eq!(s.len(), 0);
38 let args: Vec<String> = env::args().collect();
39 let mut p = Command::new(&args[0]).arg("child")
40 .stdin(Stdio::piped())
41 .stdout(Stdio::piped())
42 .stderr(Stdio::piped())
44 assert!(p.wait().unwrap().success());