2014-05-27 14:08:27 -05:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
|
2015-01-22 18:31:00 -06:00
|
|
|
use std::old_io::process;
|
|
|
|
use std::old_io::Command;
|
|
|
|
use std::old_io;
|
2014-05-27 14:08:27 -05:00
|
|
|
use std::os;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let args = os::args();
|
2015-02-01 20:53:25 -06:00
|
|
|
if args.len() > 1 && args[1] == "child" {
|
2014-05-27 14:08:27 -05:00
|
|
|
return child()
|
|
|
|
}
|
|
|
|
|
|
|
|
test();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fn child() {
|
2015-01-22 18:31:00 -06:00
|
|
|
old_io::stdout().write_line("foo").unwrap();
|
|
|
|
old_io::stderr().write_line("bar").unwrap();
|
2015-01-12 10:23:40 -06:00
|
|
|
let mut stdin = old_io::stdin();
|
|
|
|
assert_eq!(stdin.lock().read_line().err().unwrap().kind, old_io::EndOfFile);
|
2014-05-27 14:08:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test() {
|
|
|
|
let args = os::args();
|
2015-02-01 20:53:25 -06:00
|
|
|
let mut p = Command::new(&args[0]).arg("child")
|
2014-05-27 14:08:27 -05:00
|
|
|
.stdin(process::Ignored)
|
|
|
|
.stdout(process::Ignored)
|
|
|
|
.stderr(process::Ignored)
|
|
|
|
.spawn().unwrap();
|
|
|
|
assert!(p.wait().unwrap().success());
|
|
|
|
}
|