Skip to content

Commit

Permalink
Check that we get somewhat sane PIDs when spawning with pidfds
Browse files Browse the repository at this point in the history
  • Loading branch information
the8472 committed Jun 24, 2024
1 parent 3e4e31b commit ec0c755
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/std/src/sys/pal/unix/linux/pidfd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn test_command_pidfd() {
let flags = super::cvt(unsafe { libc::fcntl(pidfd.as_raw_fd(), libc::F_GETFD) }).unwrap();
assert!(flags & libc::FD_CLOEXEC != 0);
}
assert!(child.id() > 0 && child.id() < -1i32 as u32);
let status = child.wait().expect("error waiting on pidfd");
assert_eq!(status.code(), Some(1));

Expand All @@ -47,6 +48,8 @@ fn test_command_pidfd() {
let mut child =
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 {
assert!(child.pidfd().is_ok())
}
Expand Down

0 comments on commit ec0c755

Please sign in to comment.