NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | NOTES | HISTORY | SEE ALSO | COLOPHON |
|
|
SD_PIDFD_GET_INODE_ID(3) sd_pidfd_get_inode_id SD_PIDFD_GET_INODE_ID(3)
sd_pidfd_get_inode_id - Acquire the 64-bit inode ID of a PID file descriptor (PIDFD)
#include <systemd/sd-daemon.h> int sd_pidfd_get_inode_id(int pidfd, uint64_t *ret);
sd_pidfd_get_inode_id() may be invoked to acquire the 64-bit inode ID of a PID file descriptor (PIDFD), which can be used to reliably identify a process for the current boot. As a typical example, the service manager sets $MAINPIDFDID and $MANAGERPIDFDID environment variables to the inode IDs of the service main process and the service manager itself, respectively, if such functionality is supported by the kernel. On 64-bit architectures, the inode ID can be directly obtained via a call to fstat(2) on a given pidfd. However, on 32-bit architectures struct stat's .st_ino field is also 32-bit, which similar to PIDs is subject to reuse. Therefore, a second mechanism leveraging name_to_handle_at(2) has been added to kernel in v6.14. This helper is added to simplify downstream handling of pidfd/pidfs internals.
On success, the function returns 0 or a positive integer. On failure, a negative errno-style error code is returned. Errors Returned errors may indicate the following problems: -EOPNOTSUPP The stable PIDFD inode ID is not supported by the running kernel, or the system is 32-bit and name_to_handle_at() is unavailable. -EBADF The specified file descriptor is invalid, or is not a PIDFD.
Functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file.
sd_pidfd_get_inode_id() was added in version 258.
systemd(1), sd-daemon(3), sd_notify(3), systemd.exec(5)
This page is part of the systemd (systemd system and service
manager) project. Information about the project can be found at
⟨http://www.freedesktop.org/wiki/Software/systemd⟩. If you have a
bug report for this manual page, see
⟨http://www.freedesktop.org/wiki/Software/systemd/#bugreports⟩.
This page was obtained from the project's upstream Git repository
⟨https://github.com/systemd/systemd.git⟩ on 2025-08-11. (At that
time, the date of the most recent commit that was found in the
repository was 2025-08-11.) If you discover any rendering
problems in this HTML version of the page, or you believe there is
a better or more up-to-date source for the page, or you have
corrections or improvements to the information in this COLOPHON
(which is not part of the original manual page), send a mail to
[email protected]
systemd 258~rc2 SD_PIDFD_GET_INODE_ID(3)
Pages that refer to this page: sd-daemon(3), sd_notify(3), systemd.directives(7), systemd.index(7)