Check that we get somewhat sane PIDs when spawning with pidfds · rust-lang/rust@ec0c755 (original) (raw)
File tree
1 file changed
lines changed
- library/std/src/sys/pal/unix/linux/pidfd
1 file changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -21,6 +21,7 @@ fn test_command_pidfd() { | ||
| 21 | 21 | let flags = super::cvt(unsafe { libc::fcntl(pidfd.as_raw_fd(), libc::F_GETFD) }).unwrap(); |
| 22 | 22 | assert!(flags & libc::FD_CLOEXEC != 0); |
| 23 | 23 | } |
| 24 | +assert!(child.id() > 0 && child.id() < -1i32 as u32); | |
| 24 | 25 | let status = child.wait().expect("error waiting on pidfd"); |
| 25 | 26 | assert_eq!(status.code(), Some(1)); |
| 26 | 27 | |
| @@ -47,6 +48,8 @@ fn test_command_pidfd() { | ||
| 47 | 48 | let mut child = |
| 48 | 49 | unsafe { Command::new("false").pre_exec(| |
| 49 | 50 | |
| 51 | +assert!(child.id() > 0 && child.id() < -1i32 as u32); | |
| 52 | + | |
| 50 | 53 | if pidfd_open_available { |
| 51 | 54 | assert!(child.pidfd().is_ok()) |
| 52 | 55 | } |