Check that we get somewhat sane PIDs when spawning with pidfds · rust-lang/rust@ec0c755

File tree

1 file changed

lines changed

  • library/std/src/sys/pal/unix/linux/pidfd

1 file changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -21,6 +21,7 @@ fn test_command_pidfd() {

2121

let flags = super::cvt(unsafe { libc::fcntl(pidfd.as_raw_fd(), libc::F_GETFD) }).unwrap();

2222

assert!(flags & libc::FD_CLOEXEC != 0);

2323

}

24+

assert!(child.id() > 0 && child.id() < -1i32 as u32);

2425

let status = child.wait().expect("error waiting on pidfd");

2526

assert_eq!(status.code(), Some(1));

2627

@@ -47,6 +48,8 @@ fn test_command_pidfd() {

4748

let mut child =

4849

unsafe { Command::new("false").pre_exec(|| Ok(())) }.create_pidfd(true).spawn().unwrap();

4950
51+

assert!(child.id() > 0 && child.id() < -1i32 as u32);

52+
5053

if pidfd_open_available {

5154

assert!(child.pidfd().is_ok())

5255

}