[LTP] [PATCH v4] Correctly check if PIDFD_INFO_EXIT is available
    Petr Vorel 
    pvorel@suse.cz
       
    Wed Jul 30 18:36:54 CEST 2025
    
    
  
Hi Andrea, all,
> 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.
Thanks for doing the investigation and fixing this!
...
> -	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
> +		 * - EINVAL: until v6.13 kernel
> +		 * - ESRCH: all kernels between v6.13 and v6.15
> +		 */
> +		if (errno != ENOTTY &&
> +			errno != EINVAL &&
> +			errno != ESRCH)
> +			tst_brk(TBROK | TERRNO, "ioctl error");
> +	} else {
> +		if (info.mask & PIDFD_INFO_EXIT)
nit: this could have been:
	} else if (info.mask & PIDFD_INFO_EXIT) {
Kind regards,
Petr
> +			supported = 1;
> +	}
> -	if (info.mask & PIDFD_INFO_EXIT)
> -		ret = 1;
    
    
More information about the ltp
mailing list