SD_PIDFD_GET_INODE_ID(3) | sd_pidfd_get_inode_id | SD_PIDFD_GET_INODE_ID(3) |
NAME
sd_pidfd_get_inode_id - Acquire the 64-bit inode ID of a PID file descriptor (PIDFD)
SYNOPSIS
#include <systemd/sd-daemon.h>
int sd_pidfd_get_inode_id(int pidfd, uint64_t *ret);
DESCRIPTION
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.
RETURN VALUE
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
-EBADF
NOTES
Functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file.
HISTORY
sd_pidfd_get_inode_id() was added in version 258.
SEE ALSO
systemd 258 |