setpgrp(2j)
NAME
setpgrp, getpgrp − set/get process group
SYNTAX
int getpgrp(pid)
int pid;
int setpgrp(pid, pgrp)
int pid, pgrp;
cc ... −ljobs
DESCRIPTION
The setpgrp system call sets the process group of the specified process pid to the specified pgrp. If pid is zero, then the call applies to the current process. The process group of the specified process is returned by the getpgrp system call.
If the invoker is not the superuser, then the affected process must have the same effective user ID as the invoker or be a descendant of the invoking process.
This call is used by csh(1) to create process groups in implementing job control. The TIOCGPGRP and TIOCSPGRP calls described in tty(4) are used to get and set, respectively, the process group of the control terminal.
This call is found in the jobs library, libjobs.a. Another version of this call exists in the standard C library, libc.a. For further information, see setpgrp(2v).
For further information about job control, see intro(3j).
RESTRICTIONS
The job control facilities are not available in standard version 7 UNIX. These facilities are still under development and may change in future releases of the system as better inter-process communication facilities and support for virtual terminals become available. The options and specifications of these system calls and even the calls themselves are thus subject to change.
A setpgrp call has been implemented in other versions of UNIX which are not widely used outside of Bell Laboratories. The implementations have, in general, slightly different semantics.
DIAGNOSTICS
The setpgrp and setpgrp calls will fail if:
[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.
[ESRCH] The requested process does not exist.
ASSEMBLER
(setpgrp = 39.)
(process id in r0)
sys setpgrp; newgrp
(getpgrp is implemented as setpgrp(pid,-1)
sys setgrp; -1
(process group in r0)