blob: 6314dc2cd64f68b9e8bb4d5deda1a30da7a3c151 [file] [log] [blame]
Alex Crichton71982aa2015-03-31 21:41:591// 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 II0909e0b2018-08-30 12:18:5511// run-pass
Felix S. Klock IIc9d9cc62018-09-25 21:51:3512#![allow(unused_imports)]
Ed Schouten3f880912018-01-02 13:11:4113// ignore-cloudabi no processes
Alex Crichtond9ecdfe2017-10-18 01:45:4214// ignore-emscripten no processes
Jan-Erik Redigerad918732016-08-08 23:39:3715
Alex Crichton71982aa2015-03-31 21:41:5916use std::env;
17use std::process::{self, Command, Stdio};
18
19fn 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
28fn 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
34fn child() -> i32 {
35 process::exit(2);
36}