]> git.lizzy.rs Git - rust.git/blob - tests/ui/weird-exit-code.rs
Rollup merge of #107700 - jyn514:tools-builder, r=Mark-Simulacrum
[rust.git] / tests / ui / weird-exit-code.rs
1 // run-pass
2 // On Windows the GetExitCodeProcess API is used to get the exit code of a
3 // process, but it's easy to mistake a process exiting with the code 259 as
4 // "still running" because this is the value of the STILL_ACTIVE constant. Make
5 // sure we handle this case in the standard library and correctly report the
6 // status.
7 //
8 // Note that this is disabled on unix as processes exiting with 259 will have
9 // their exit status truncated to 3 (only the lower 8 bits are used).
10
11 #[cfg(windows)]
12 fn main() {
13     use std::process::{self, Command};
14     use std::env;
15
16     if env::args().len() == 1 {
17         let status = Command::new(env::current_exe().unwrap())
18                              .arg("foo")
19                              .status()
20                              .unwrap();
21         assert_eq!(status.code(), Some(259));
22     } else {
23         process::exit(259);
24     }
25 }
26
27 #[cfg(not(windows))]
28 fn main() {}