setpgrp() — Set process group ID

Standards

Standards / Extensions C or C++ Dependencies

XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <unistd.h>

pid_t setpgrp(void);

General description

If the calling process is not already a session leader, setpgrp() sets the process group ID of the calling process to the process ID of the calling process. If a new process group is created, it is created within the session of the calling process.

Returned value

If successful, setpgrp() returns the new process group ID.

If unsuccessful, setpgrp() returns -1 and sets errno to one of the following values:
Error Code
Description
EPERM
The calling process is a session leader.

Related information