getpid
Getpid is a POSIX-compliant library function that returns the process identifier (PID) of the calling process. It is commonly used in C and other languages that provide POSIX interfaces. The function is declared in unistd.h and returns a value of type pid_t, a type defined in sys/types.h.
The PID is a unique identifier assigned by the kernel to each active process within the system.
Threads and PID semantics: All threads within a single process share the same PID, since they belong
Usage example in C: pid_t pid = getpid(); printf("PID: %d\n", (int)pid);
Portability and related functions: getpid is part of the POSIX standard, and equivalents or wrappers exist
See also: getppid (parent process ID), fork (process creation), pid_t, unistd.h, sys/types.h.