rust/tests/ui/process/process-exit.rs
许杰友 Jieyou Xu (Joe) 635a06b595 tests: cleanup tests/ui/process/process-exit.rs
- Remove unnecessary `#![allow(unused_imports)]`.
- Replace `ignore-*` with `needs-subprocess`.
2025-01-23 20:51:29 +08:00

24 lines
475 B
Rust

//@ run-pass
//@ needs-subprocess
use std::env;
use std::process::{self, Command};
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "child" {
child();
} else {
parent();
}
}
fn parent() {
let args: Vec<String> = env::args().collect();
let status = Command::new(&args[0]).arg("child").status().unwrap();
assert_eq!(status.code(), Some(2));
}
fn child() -> i32 {
process::exit(2);
}