]> git.lizzy.rs Git - rust.git/blob - tests/ui/process/process-exit.rs
Rollup merge of #107194 - xfix:remove-slice-internals-dependency-in-rustc-ast, r...
[rust.git] / tests / ui / process / process-exit.rs
1 // run-pass
2 #![allow(unused_imports)]
3 // ignore-emscripten no processes
4 // ignore-sgx no processes
5
6 use std::env;
7 use std::process::{self, Command, Stdio};
8
9 fn main() {
10     let args: Vec<String> = env::args().collect();
11     if args.len() > 1 && args[1] == "child" {
12         child();
13     } else {
14         parent();
15     }
16 }
17
18 fn parent() {
19     let args: Vec<String> = env::args().collect();
20     let status = Command::new(&args[0]).arg("child").status().unwrap();
21     assert_eq!(status.code(), Some(2));
22 }
23
24 fn child() -> i32 {
25     process::exit(2);
26 }