1 // Check that statically linked binary executes successfully
2 // with RLIMIT_NOFILE resource lowered to zero. Regression
3 // test for issue #96621.
6 // dont-check-compiler-stderr
9 // compile-flags: -Ctarget-feature=+crt-static -Crpath=no -Crelocation-model=static
10 #![feature(exit_status_error)]
11 #![feature(rustc_private)]
14 use std::os::unix::process::CommandExt;
15 use std::process::Command;
18 let mut args = std::env::args();
19 let this = args.next().unwrap();
20 match args.next().as_deref() {
22 let mut cmd = Command::new(this);
26 let rlim = libc::rlimit {
30 if libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) == -1 {
31 Err(std::io::Error::last_os_error())
37 let output = cmd.output().unwrap();
38 println!("{:?}", output);
39 output.status.exit_ok().unwrap();
40 assert!(output.stdout.starts_with(b"Ok!"));