The
setpgid()
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.
If
pgrp
is zero, then the process id of the process specified by
pid
is used instead.
If the affected process is not the invoking process, then it must be a
child of the invoking process, it must not have performed an
exec(3)
operation, and both processes must be in the same session.
The requested process group ID must already exist in the session of
the caller, or it must be equal to the target process ID.