Alex Crichton | 71982aa | 2015-03-31 21:41:59 | [diff] [blame] | 1 | // Copyright 2015 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. |
| 4 | // |
| 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. |
| 10 | |
Felix S. Klock II | 0909e0b | 2018-08-30 12:18:55 | [diff] [blame] | 11 | // run-pass |
Felix S. Klock II | c9d9cc6 | 2018-09-25 21:51:35 | [diff] [blame^] | 12 | #![allow(unused_imports)] |
Ed Schouten | 3f88091 | 2018-01-02 13:11:41 | [diff] [blame] | 13 | // ignore-cloudabi no processes |
Alex Crichton | d9ecdfe | 2017-10-18 01:45:42 | [diff] [blame] | 14 | // ignore-emscripten no processes |
Jan-Erik Rediger | ad91873 | 2016-08-08 23:39:37 | [diff] [blame] | 15 | |
Alex Crichton | 71982aa | 2015-03-31 21:41:59 | [diff] [blame] | 16 | use std::env; |
| 17 | use std::process::{self, Command, Stdio}; |
| 18 | |
| 19 | fn main() { |
| 20 | let args: Vec<String> = env::args().collect(); |
| 21 | if args.len() > 1 && args[1] == "child" { |
| 22 | child(); |
| 23 | } else { |
| 24 | parent(); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | fn parent() { |
| 29 | let args: Vec<String> = env::args().collect(); |
| 30 | let status = Command::new(&args[0]).arg("child").status().unwrap(); |
| 31 | assert_eq!(status.code(), Some(2)); |
| 32 | } |
| 33 | |
| 34 | fn child() -> i32 { |
| 35 | process::exit(2); |
| 36 | } |