[LTP] [PATCH] Correctly check if PIDFD_INFO_EXIT is available
Andrea Cervesato
andrea.cervesato@suse.de
Tue Jul 29 15:38:13 CEST 2025
From: Andrea Cervesato <andrea.cervesato@suse.com>
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
error like a sign for not having PIDFD_INFO_EXIT implemented in the
system.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/syscalls/ioctl/ioctl_pidfd.h | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd.h b/testcases/kernel/syscalls/ioctl/ioctl_pidfd.h
index 8249ac753cf7fb8a3b749d55c7f0c3b30482c114..b2de5389ef78e530e1a3be0525b0a6a238d1d009 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd.h
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd.h
@@ -11,7 +11,7 @@
static inline int ioctl_pidfd_info_exit_supported(void)
{
- int ret = 0;
+ int ret;
pid_t pid;
int pidfd;
struct pidfd_info info;
@@ -29,13 +29,17 @@ 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);
-
- if (info.mask & PIDFD_INFO_EXIT)
- ret = 1;
+ ret = ioctl(pidfd, PIDFD_GET_INFO, &info);
+ if (ret == -1) {
+ if (errno != ENOTTY)
+ tst_brk(TBROK | TERRNO, "ioctl error");
+ } else {
+ if (info.mask & PIDFD_INFO_EXIT)
+ return 1;
+ }
- return ret;
+ SAFE_CLOSE(pidfd);
+ return 0;
}
#endif
---
base-commit: 91e6272febf95e19a8300695dfc2089569adf9d8
change-id: 20250729-ioctl_pidfd_supported-437d25a4c382
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
More information about the ltp
mailing list