getpgid Subroutine

Purpose

Returns the process group ID of the calling process.

Library

Standard C Library (libc.a)

Syntax

#include <unistd.h>

pid_t getpgid (Pid)
(pid_ Pid)

Description

The getpgid subroutine returns the process group ID of the process whose process ID is equal to that specified by the Pid parameter. If the value of the Pid parameter is equal to (pid_t)0, the getpgid subroutine returns the process group ID of the calling process.

Parameter

Item Description
Pid The process ID of the process to return the process group ID for.

Return Values

Item Description
id The process group ID of the requested process
-1 Not successful and errno set to one of the following.

Error Code

Item Description
ESRCH There is no process with a process ID equal to Pid.
Item Description
EPERM The process whose process ID is equal to Pid is not in the same session as the calling process.
EINVAL The value of the Pid argument is invalid.