also handle ENOTTY ioctl errors when checking pidfd -> pid support
Otherwise the std testsuite fails on older kernels.
This commit is contained in:
parent
44a5b55557
commit
5435e8188c
2 changed files with 4 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue