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)](/man/os/systemd/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)](/man/os/systemd/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)](/man/os/systemd/pkg-config.1) file.

.SH "HISTORY"

.PP **sd\_pidfd\_get\_inode\_id()** was added in version 258.

.SH "SEE ALSO"

.PP [**systemd**(1)](/man/os/systemd/systemd.1), [**sd-daemon**(3)](/man/os/systemd/sd-daemon.3), [**sd\_notify**(3)](/man/os/systemd/sd_notify.3), [**systemd.exec**(5)](/man/os/systemd/systemd.exec.5)

systemd 262.2

---

Document: sd_pidfd_get_inode_id(3) from systemd 262.2-r1 (Chainguard OS)
Source: https://github.com/systemd/systemd
