The file descriptor returned by the pidfd_fork function can be used to
query process extra information.
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:
EBADFThe input file descriptor is invalid, does not have a pidfd associated, or an error has occurred parsing the kernel data.
EREMOTEThere is no process ID to denote the process in the current namespace.
ESRCHThe process for which the file descriptor refers to is terminated.
ENOENTThe procfs is not mounted.
ENFILE.Too many open files in system (pidfd_open tries to open a procfs file and
read its contents).
ENOMEMInsufficient kernel memory was available.
This function is specific to Linux.