2019-07-26 21:54:25 +00:00
|
|
|
//@ run-pass
|
2024-03-06 20:44:54 +00:00
|
|
|
//@ ignore-wasm32 spawning processes is not supported
|
2019-04-24 16:26:33 +00:00
|
|
|
//@ ignore-sgx no processes
|
2017-05-10 19:28:25 +00:00
|
|
|
|
2017-01-21 18:38:11 +00:00
|
|
|
use std::{env, process};
|
|
|
|
|
|
|
|
fn child() {
|
|
|
|
print!("[stdout 0]");
|
|
|
|
print!("[stdout {}]", 1);
|
|
|
|
println!("[stdout {}]", 2);
|
|
|
|
println!();
|
|
|
|
eprint!("[stderr 0]");
|
|
|
|
eprint!("[stderr {}]", 1);
|
|
|
|
eprintln!("[stderr {}]", 2);
|
|
|
|
eprintln!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent() {
|
|
|
|
let this = env::args().next().unwrap();
|
|
|
|
let output = process::Command::new(this).arg("-").output().unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
let stdout = String::from_utf8(output.stdout).unwrap();
|
|
|
|
let stderr = String::from_utf8(output.stderr).unwrap();
|
|
|
|
|
|
|
|
assert_eq!(stdout, "[stdout 0][stdout 1][stdout 2]\n\n");
|
|
|
|
assert_eq!(stderr, "[stderr 0][stderr 1][stderr 2]\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if env::args().count() == 2 { child() } else { parent() }
|
|
|
|
}
|