diff --git a/library/std/src/sys/pal/unix/linux/pidfd.rs b/library/std/src/sys/pal/unix/linux/pidfd.rs index e9e4831fcc02b..671046949aa16 100644 --- a/library/std/src/sys/pal/unix/linux/pidfd.rs +++ b/library/std/src/sys/pal/unix/linux/pidfd.rs @@ -33,7 +33,7 @@ impl PidFd { match cvt(unsafe { libc::ioctl(self.0.as_raw_fd(), libc::PIDFD_GET_INFO, &mut pidfd_info) }) { Ok(_) => {} - Err(e) if e.raw_os_error() == Some(libc::EINVAL) => { + Err(e) if matches!(e.raw_os_error(), Some(libc::EINVAL | libc::ENOTTY)) => { // kernel doesn't support that ioctl, try the glibc helper that looks at procfs weak!( fn pidfd_getpid(pidfd: RawFd) -> libc::pid_t; diff --git a/library/std/src/sys/pal/unix/linux/pidfd/tests.rs b/library/std/src/sys/pal/unix/linux/pidfd/tests.rs index a3bb5d5d64ba5..0330f28e647d3 100644 --- a/library/std/src/sys/pal/unix/linux/pidfd/tests.rs +++ b/library/std/src/sys/pal/unix/linux/pidfd/tests.rs @@ -1,6 +1,5 @@ use super::PidFd as InternalPidFd; use crate::assert_matches::assert_matches; -use crate::io::ErrorKind; use crate::os::fd::AsRawFd; use crate::os::linux::process::{ChildExt, CommandExt as _}; use crate::os::unix::process::{CommandExt as _, ExitStatusExt}; @@ -62,7 +61,9 @@ fn test_command_pidfd() { if let Ok(pidfd) = child.pidfd() { match pidfd.as_inner().pid() { Ok(pid) => assert_eq!(pid, id), - Err(e) if e.kind() == ErrorKind::InvalidInput => { /* older kernel */ } + Err(e) if matches!(e.raw_os_error(), Some(libc::EINVAL | libc::ENOTTY)) => { + /* older kernel */ + } Err(e) => panic!("unexpected error getting pid from pidfd: {}", e), } }