---
name: "sd_pidfd_get_inode_id"
section: "3"
platform: "linux"
package: "systemd-libs"
version: "262.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/sd_pidfd_get_inode_id"
---

# sd\_pidfd\_get\_inode\_id(3)

Acquire the 64-bit inode ID of a PID file descriptor (PIDFD)

## 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)](/fstat/2.md) 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)](/name_to_handle_at/2.md) 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**

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.

## NOTES

Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/pkg-config/1.md) file.

## HISTORY

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

## SEE ALSO

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