27.5 Querying a Process

The file descriptor returned by the pidfd_fork function can be used to query process extra information.

Function: pid_t pidfd_getpid (int fd)

Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

The pidfd_getpid function retrieves the process ID associated with process file descriptor created with pid_spawn, pidfd_fork, or pidfd_open.

If the operation fails, pidfd_getpid return -1 and the following errno error conditionas are defined:

EBADF

The input file descriptor is invalid, does not have a pidfd associated, or an error has occurred parsing the kernel data.

EREMOTE

There is no process ID to denote the process in the current namespace.

ESRCH

The process for which the file descriptor refers to is terminated.

ENOENT

The procfs is not mounted.

ENFILE.

Too many open files in system (pidfd_open tries to open a procfs file and read its contents).

ENOMEM

Insufficient kernel memory was available.

This function is specific to Linux.