Check that we get somewhat sane PIDs when spawning with pidfds

This commit is contained in:
The 8472 2024-06-25 00:17:31 +02:00
parent 3e4e31b7bf
commit ec0c755704

View File

@ -21,6 +21,7 @@ fn test_command_pidfd() {
let flags = super::cvt(unsafe { libc::fcntl(pidfd.as_raw_fd(), libc::F_GETFD) }).unwrap(); let flags = super::cvt(unsafe { libc::fcntl(pidfd.as_raw_fd(), libc::F_GETFD) }).unwrap();
assert!(flags & libc::FD_CLOEXEC != 0); assert!(flags & libc::FD_CLOEXEC != 0);
} }
assert!(child.id() > 0 && child.id() < -1i32 as u32);
let status = child.wait().expect("error waiting on pidfd"); let status = child.wait().expect("error waiting on pidfd");
assert_eq!(status.code(), Some(1)); assert_eq!(status.code(), Some(1));
@ -47,6 +48,8 @@ fn test_command_pidfd() {
let mut child = let mut child =
unsafe { Command::new("false").pre_exec(|| Ok(())) }.create_pidfd(true).spawn().unwrap(); unsafe { Command::new("false").pre_exec(|| Ok(())) }.create_pidfd(true).spawn().unwrap();
assert!(child.id() > 0 && child.id() < -1i32 as u32);
if pidfd_open_available { if pidfd_open_available {
assert!(child.pidfd().is_ok()) assert!(child.pidfd().is_ok())
} }