getpgrp
Getpgrp is a Unix-like system call that returns the process group ID (PGID) of a process. Process groups are a fundamental part of job control: a terminal has a foreground process group, and signals such as SIGINT are delivered to all processes in that group. The PGID is also used to organize related processes so that signals and terminal control can be managed as a unit.
POSIX defines a portable interface for obtaining a process group ID via getpgid(pid_t pid). This function returns
Usage typically appears in C code by including unistd.h (and related headers): pid_t pgid = getpgrp(void); or
Return values and errors: On success, the function returns the process group ID. On error, it returns
Notes: For portable code, prefer getpgid(pid) as defined by POSIX. getpgrp remains a historical alias on some