getpgid()

Get a process group ID

Synopsis:

#include <unistd.h>

pid_t getpgid( pid_t pid );

Arguments:

pid
The ID of the process whose process group ID you want to get.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The getpgid() returns the group ID for the process specified by pid. If pid is 0, getpgid() returns the calling process's group ID.

The following definitions are worth mentioning:

Process
An executing instance of a program, identified by a nonnegative integer called a process ID.
Process group
A collection of one or more processes, with a unique process group ID. A process group ID is a positive integer.

Returns:

A process group ID for success, or (pid_t)-1 if an error occurs.

Errors:

If an error occurs, errno is set to:

ESRCH
The process specified by pid doesn't exist.

Classification:

POSIX 1003.1 XSI

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

getsid(), setpgid(), setsid()