getpgid
getpgid is a POSIX function that returns the process group ID (PGID) of a process. Process groups are used for job control, allowing a group of related processes to be managed together, such as receiving signals or controlling terminal access.
The function is declared as pid_t getpgid(pid_t pid). If pid is 0, the PGID of the calling
On success, getpgid returns the process group ID as a positive integer. On failure, it returns -1
Usage examples include querying the PGID of another process to determine group membership, or using a negative
getpgid is available on most Unix-like systems that implement POSIX, including Linux, BSD variants, and macOS.