getpgid() — Get process group ID
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <unistd.h>
pid_t getpgid(pid_t pid);
General description
The getpgid() function returns the process group ID of the process whose process ID is equal to pid. If pid is 0, getpgid() returns the PID of the calling process.
Returned value
If successful, getpgid() returns a process group ID.
If unsuccessful, getpgid() returns
(pid_t)-1 and sets errno to one of the following values:
- Error Code
- Description
- EPERM
- The process whose process ID is equal to pid is not the same session as the calling process, and the implementation does not allow to the process group ID of that process from the calling process.
- ESRCH
- There is no process with a process ID equal to pid.
getpgid() may fail if:
- Error Code
- Description
- EINVAL
- The value of the pid argument is not valid.