Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec(2)

fork(2)

getpid(2)

getuid(2)

intro(2)

kill(2)

signal(2)

tty(4)

SETPGRP(2V)  —  SYSTEM CALLS

NAME

setpgrp, getpgrp − set and/or return the process group of a process

SYNOPSIS

setpgrp(pid, pgrp)
pgrp = getpgrp(pid)
int pgrp;
int pid;
int pid, pgrp;

SYSTEM V SYNOPSIS

int setpgrp()

DESCRIPTION

Setpgrp

setpgrp sets the process group of the specified process, (pid) to the specified pgrp. If pid is zero, then the call applies to the current (calling) process. 

If the effective user ID is not that of the super-user, then the process to be affected must have the same effective user ID as that of the caller or be a descendant of that process. 

Getpgrp

getpgrp returns the process group of the indicated process.  If pid is zero, then the call applies to the calling process. 

Process groups are used for distribution of signals, and by terminals to arbitrate requests for their input.  Processes that have the same process group as the terminal run in the foreground and may read from the terminal, while others block with a signal when they attempt to read. 

This call is thus used by programs such as csh(1) to create process groups in implementing job control. The TIOCGPGRP and TIOCSPGRP calls described in tty(4) are used to get/set the process group of the control terminal.

RETURN VALUE

setpgrp returns 0 when the operation was successful.  If the request failed, −1 is returned and the global variable errno indicates the reason. 

ERRORS

setpgrp fails, and the process group is not altered when one of the following occurs:

ESRCH The requested process does not exist. 

EPERM The effective user ID of the requested process is different from that of the caller and the process is not a descendent of the calling process. 

SYSTEM V DESCRIPTION

In the System V implementation, setpgrp takes no parameters.  It sets the process group of the calling process to match its process ID, and returns the new process group ID. 

SEE ALSO

exec(2), fork(2), getpid(2), getuid(2), intro(2), kill(2), signal(2), tty(4)

Sun Release 3.2  —  Last change: 10 June 1986

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026