[LTP] [PATCH v4] Correctly check if PIDFD_INFO_EXIT is available
Cyril Hrubis
chrubis@suse.cz
Wed Jul 30 16:28:24 CEST 2025
Hi!
> When systems are not having the PIDFD_INFO_EXIT implementation,
> ioctl_pidfd testing suite might fail with:
>
> ioctl_pidfd.h:32: TBROK: ioctl(...) failed: ENOTTY (25)
>
> Fix the ioctl_pidfd_info_exit_supported() behavior, considering ENOTTY,
> EINVAL and ESRCH errors like a sign for not having PIDFD_INFO_EXIT
> implemented in the system.
> if (tst_kvercmp(6, 15, 0) >= 0)
> @@ -29,13 +30,24 @@ static inline int ioctl_pidfd_info_exit_supported(void)
> pidfd = SAFE_PIDFD_OPEN(pid, 0);
> SAFE_WAITPID(pid, NULL, 0);
>
> - SAFE_IOCTL(pidfd, PIDFD_GET_INFO, &info);
> - SAFE_CLOSE(pidfd);
> + ret = ioctl(pidfd, PIDFD_GET_INFO, &info);
> + if (ret == -1) {
> + /* - ENOTTY: old kernels not implementing fs/pidfs.c:pidfd_ioctl
Okay that's what we get if there is no ioctl() handler for the pidfs.
> + * - EINVAL: until v6.13 kernel
And this is supposedly before PIDFD_GET_INFO was added.
> + * - ESRCH: all kernels between v6.13 and v6.15
I suppose what happens between 6.13 and 6.15 is that PIDFD_GET_INFO is
acutally implemented but all the data about the process are gone once it
has been waited for. I was thinking that we could eliminate this branch
if we waited for the process after the ioctl() but we need the actual
process to exit since otherwise the PIFD_INFO_EXIT flag woudln't be set
in the result even if it's supported. Sigh.
So I guess that we cannot make this any simpler.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list