getppid2
Get process identification
Part of getpid(2).
Usage
#include <unistd.h>
pid_t getpid(void); pid_t getppid(void);
Library
Standard C library (libc, -lc)
Overview
getpid() returns the process ID (PID) of the calling process. (This is often used by routines that generate unique temporary filenames.)
getppid() returns the process ID of the parent of the calling process. This will be either the ID of the process that created this process using fork(), or, if that process has already terminated, the ID of the process to which this process has been reparented (either init(1) or a "subreaper" process defined via the prctl(2) PR_SET_CHILD_SUBREAPER operation).
Errors
These functions are always successful.
Versions
On Alpha, instead of a pair of getpid() and getppid() system calls, a single getxpid() system call is provided, which returns a pair of PID and parent PID. The glibc getpid() and getppid() wrapper functions transparently deal with this. See syscall(2) for details regarding register mapping.
Notes
If the caller's parent is in a different PID namespace (see pid_namespaces(7)), getppid() returns 0.
From a kernel perspective, the PID (which is shared by all of the threads in a multithreaded process) is sometimes also known as the thread group ID (TGID). This contrasts with the kernel thread ID (TID), which is unique for each thread. For further details, see gettid(2) and the discussion of the CLONE_THREAD flag in clone(2).
Releases
19 releases since Debian 1.1 (Buzz); the text changed 14 times.