mirror_ubuntu-kernels/tools/testing/selftests/pidfd
Luca Boccassi cdda1f26e7
pidfd: add ioctl to retrieve pid info
A common pattern when using pid fds is having to get information
about the process, which currently requires /proc being mounted,
resolving the fd to a pid, and then do manual string parsing of
/proc/N/status and friends. This needs to be reimplemented over
and over in all userspace projects (e.g.: I have reimplemented
resolving in systemd, dbus, dbus-daemon, polkit so far), and
requires additional care in checking that the fd is still valid
after having parsed the data, to avoid races.

Having a programmatic API that can be used directly removes all
these requirements, including having /proc mounted.

As discussed at LPC24, add an ioctl with an extensible struct
so that more parameters can be added later if needed. Start with
returning pid/tgid/ppid and creds unconditionally, and cgroupid
optionally.

Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Link: https://lore.kernel.org/r/20241010155401.2268522-1-luca.boccassi@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-10-24 13:54:51 +02:00
..
.gitignore selftests/pidfd: add pidfd setns tests 2020-05-13 11:41:22 +02:00
config selftests/pidfd: Fix config for pidfd_setns_test 2024-05-11 19:18:39 +02:00
Makefile selftests: pidfd: Fix incorrect kernel headers search path 2023-02-13 09:09:45 -07:00
pidfd_fdinfo_test.c selftests: pidfd: ksft_exit functions do not return 2024-05-06 13:57:20 -06:00
pidfd_getfd_test.c selftests: add ESRCH tests for pidfd_getfd() 2024-02-07 15:48:31 +01:00
pidfd_open_test.c pidfd: add ioctl to retrieve pid info 2024-10-24 13:54:51 +02:00
pidfd_poll_test.c selftests: pidfd: ksft_exit functions do not return 2024-05-06 13:57:20 -06:00
pidfd_setns_test.c pidfs: add selftests for new namespace ioctls 2024-07-24 10:53:13 +02:00
pidfd_test.c selftests: pidfd: ksft_exit functions do not return 2024-05-06 13:57:20 -06:00
pidfd_wait.c selftests: pidfd: Fix compling warnings 2022-10-30 02:23:58 -06:00
pidfd.h selftest: pidfd: Omit long and repeating outputs 2023-06-12 16:39:11 -06:00