]>
Commit | Line | Data |
---|---|---|
416331ca | 1 | // run-pass |
2c00a5a8 | 2 | // ignore-cloudabi spawning processes is not supported |
7cac9316 | 3 | // ignore-emscripten spawning processes is not supported |
48663c56 | 4 | // ignore-sgx no processes |
7cac9316 XL |
5 | |
6 | use std::{env, process}; | |
7 | ||
8 | fn child() { | |
9 | print!("[stdout 0]"); | |
10 | print!("[stdout {}]", 1); | |
11 | println!("[stdout {}]", 2); | |
12 | println!(); | |
13 | eprint!("[stderr 0]"); | |
14 | eprint!("[stderr {}]", 1); | |
15 | eprintln!("[stderr {}]", 2); | |
16 | eprintln!(); | |
17 | } | |
18 | ||
19 | fn parent() { | |
20 | let this = env::args().next().unwrap(); | |
21 | let output = process::Command::new(this).arg("-").output().unwrap(); | |
22 | assert!(output.status.success()); | |
23 | ||
24 | let stdout = String::from_utf8(output.stdout).unwrap(); | |
25 | let stderr = String::from_utf8(output.stderr).unwrap(); | |
26 | ||
27 | assert_eq!(stdout, "[stdout 0][stdout 1][stdout 2]\n\n"); | |
28 | assert_eq!(stderr, "[stderr 0][stderr 1][stderr 2]\n\n"); | |
29 | } | |
30 | ||
31 | fn main() { | |
32 | if env::args().count() == 2 { child() } else { parent() } | |
33 | } |