[PATCH 02/13] Update PIDFD_* constants for Linux 6.17

Yury Khrustalev yury.khrustalev@arm.com
Thu Nov 6 14:59:27 GMT 2025


On Fri, Oct 03, 2025 at 04:38:53PM -0300, Adhemerval Zanella wrote:
> The pidfd interface was extended with:
> 
>   * PIDFD_GET_INFO and pidfd_info (along with related extra flags) to
>     allow get information about the process without the need to parse
>     /proc (commit cdda1f26e74ba, Linux 6.13).
> 
>   * PIDFD_SELF_{THREAD,THREAD_GROUP,SELF,SELF_PROCESS} to allow
>     pidfd_send_signal refer to the own process or thread lead groups
>     without the need of allocating a file descriptor (commit f08d0c3a71114,
>     Linux 6.15).
> 
>   * PIDFD_INFO_COREDUMP that extends PIDFD_GET_INFO to obtain coredump
>     information.
> 
> Linux uAPI header defines both PIDFD_SELF_THREAD and
> PIDFD_SELF_THREAD_GROUP on linux/fcntl.h (since they reserve part of the
> AT_* values), however for glibc I do not see any good reason to add pidfd
> definitions on fcntl-linux.h.
> 
> The tst-pidfd.c is extended with some PIDFD_SELF_* tests and a new
> ‘tst-pidfd_getinfo.c’ test is added to check PIDFD_GET_INFO. The
> PIDFD_INFO_COREDUMP tests would require very large and complex tests
> that are already covered by kernel tests.
> 
> Checked on aarch64-linux-gnu and x86_64-linux-gnu on kernels 6.8 and
> 6.17.
> ---
>  sysdeps/unix/sysv/linux/Makefile            |  1 +
>  sysdeps/unix/sysv/linux/sys/pidfd.h         | 58 +++++++++++++++++
>  sysdeps/unix/sysv/linux/tst-pidfd-consts.py |  2 +-
>  sysdeps/unix/sysv/linux/tst-pidfd.c         | 44 ++++++++++++-
>  sysdeps/unix/sysv/linux/tst-pidfd_getinfo.c | 71 +++++++++++++++++++++
>  5 files changed, 172 insertions(+), 4 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/tst-pidfd_getinfo.c

The misc/tst-pidfd_getinfo test fails with

  error: ../sysdeps/unix/sysv/linux/tst-pidfd_getinfo.c:52: ioctl (PIDFD_GET_INFO) failed: Invalid argument

on aarch64 with kernel 6.12 and passes on a system with kernel 6.17 and 6.18.

It also fails the misc/tst-pidfd-consts test when done via the
build-many-glibc.py script for some targets:

  First source:
  #include <sys/pidfd.h>


  Second source:
  #include <asm/fcntl.h>
  #include <linux/pidfd.h>


  Different values for PIDFD_SELF_PROCESS: -10001 != -20000
  Different values for PIDFD_SELF_THREAD_GROUP: -10001 != -20000

> ...
> +  int pidfd = pidfd_open (getpid(), 0);
> +  TEST_VERIFY (pidfd >= 0);
> +
> +  int pid = pidfd_getpid (pidfd);
> +  TEST_VERIFY (pid >= 0);
> +
> +  struct pidfd_info info = {
> +    .mask = PIDFD_INFO_CGROUPID,
> +  };
> +  if (ioctl (pidfd, PIDFD_GET_INFO, &info) != 0)
> +    {
> +      if (errno == ENOTTY)

Did you mean EINVAL here?

> +	FAIL_UNSUPPORTED ("kernel does not support PIDFD_GET_INFO");
> +      else
> +	FAIL_EXIT1 ("ioctl (PIDFD_GET_INFO) failed: %m");
> +    }
> +  

Thanks,
Yury



More information about the Libc-alpha mailing list