[LTP] [PATCH] Introduce ioctl_pidfd_get_info_supported() function
Petr Vorel
pvorel@suse.cz
Mon Sep 22 23:07:23 CEST 2025
Hi Avinesh,
thanks for fixing this!
...
> if (ret == -1) {
> + if (errno == ENOTTY)
> + return -1;
> +
> + if (errno == EINVAL || errno == ESRCH)
> + return 0;
> +
> + tst_brk(TBROK | TERRNO, "unexpected ioctl(PIDFD_GET_INFO) error");
> }
> - SAFE_CLOSE(pidfd);
> + return info.mask;
Because ioctl_pidfd_get_info_supported() returns 3 different states
(-1 (not supported), 0 (supported) and >= 0 (mask) it wouldn't harm to document
return type.
All the more so because ioctl_pidfd_info_exit_supported() uses reversed
conditions for supported (1) / not supported (0).
I understand chosen values, but because names suggest the same functionality doc
would help.
> +}
> +
> +static inline int ioctl_pidfd_info_exit_supported(void)
This could be bool, that's itself a documentation (just 2 possible values, not
more).
Kind regards,
Petr
> +{
> + long mask;
> +
> + if (tst_kvercmp(6, 15, 0) >= 0)
> + return 1;
> +
> + mask = ioctl_pidfd_get_info_supported();
> + if (mask == -1)
> + return 0;
> - return supported;
> + return !!(mask & PIDFD_INFO_EXIT);
> }
More information about the ltp
mailing list