| SD_PIDFD_GET_INODE_ID(3) | sd_pidfd_get_inode_id | SD_PIDFD_GET_INODE_ID(3) |
.SH "NAME" sd_pidfd_get_inode_id - Acquire the 64-bit inode ID of a
PID file descriptor (PIDFD)
.SH "SYNOPSIS"
#include <systemd/sd-daemon.h>
.HP 624u int sd_pidfd_get_inode_id(int pidfd,
uint64_t *ret);
.SH "DESCRIPTION"
.PP 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.
.PP 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.
.PP 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.
.SH "RETURN VALUE"
.PP On success, the function returns 0 or a positive integer. On failure, a
negative errno-style error code is returned.
.SS "Errors"
.PP Returned errors may indicate the following problems:
.PP -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.
.RE
.PP -EBADF
The specified file descriptor is invalid, or is not a PIDFD.
.RE
.SH "NOTES"
.PP Functions described here are available as a shared library, which can be
compiled against and linked to with the
libsystemd pkg-config(1) file.
.SH "HISTORY"
.PP sd_pidfd_get_inode_id() was added in version 258.
.SH "SEE ALSO"
| systemd 262.2 |