[LTP] [PATCH v2] Introduce ioctl_pidfd_get_info_supported() function
Petr Vorel
pvorel@suse.cz
Tue Sep 23 11:43:32 CEST 2025
Hi Avinesh,
...
> if (ret == -1) {
> - /* - ENOTTY: old kernels not implementing fs/pidfs.c:pidfd_ioctl
> - * - EINVAL: until v6.13 kernel
> - * - ESRCH: all kernels between v6.13 and v6.15
> + /* - ENOTTY: kernel too old, ioctl(PIDFD_GET_INFO) not implemented; return -1 */
> + if (errno == ENOTTY)
> + return -1;
> +
> + /* - EINVAL: ioctl(PIDFD_GET_INFO) exists but invalid args
> + * - ESRCH: ioctl(PIDFD_GET_INFO) exists but task already exited
> + * both mean supported, but info.mask is not set; return 0
> */
I originally mean to move the docs above function signature (to the top)
and add it for both, but I suppose this is perfectly ok (it was here before).
Thanks for improving it.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> - if (errno != ENOTTY &&
> - errno != EINVAL &&
> - errno != ESRCH)
> - tst_brk(TBROK | TERRNO, "ioctl error");
> - } else {
> - if (info.mask & PIDFD_INFO_EXIT)
> - supported = 1;
> + if (errno == EINVAL || errno == ESRCH)
> + return 0;
> +
> + tst_brk(TBROK | TERRNO, "unexpected ioctl(PIDFD_GET_INFO) error");
> }
> - SAFE_CLOSE(pidfd);
> + /* ioctl(PIDFD_GET_INFO) successful; return mask */
> + return info.mask;
> +}
> +
> +static inline bool ioctl_pidfd_info_exit_supported(void)
> +{
...
More information about the ltp
mailing list