COHERENT manpages

This page displays the COHERENT manpage for setpgid() [Set the process-group identifier].

List of available manpages
Index


setpgid() -- System Call (libc)

Set the process-group identifier
#include <sys/types.h>
#include <unistd.h>
int setpgid(pid, pgid)
pid_t pid, pgid;

setpgid() sets  to pgid  the process-group  identifier of the  process with
identifier pid.  If pgid  equals pid,  the process becomes  a process-group
leader.  If  pgid does not  equal pid, the  process becomes a  member of an
existing process group.

If pid  equals zero, setpgid()  uses the process identifier  of the calling
process.   If pgid  equals zero,  the  process specified  by pid  becomes a
process-group leader.

If all goes well, setpgid() returns a value of zero.  Otherwise, it returns
-1  and sets  errno  to an  appropriate  value.  setpgid()  if  any of  the
following are true:

-> pid matches  the process  identifier of a  child process of  the calling
   process,  and that  child process  has  successfully executed  an exec()
   function.  setpgid() sets errno to EACCES.

-> pgid is  less than zero or  greater than or equal  to PID_MAX. setpgid()
   sets errno to EINVAL.

-> The calling process has a controlling terminal that does not support job
   control.  setpgid() sets errno to EINVAL.

-> The process  identified by pid argument is  a session leader.  setpgid()
   sets errno to EPERM.

-> pid  equals the  process identifier  of a child  process of  the calling
   process, and the child process is not in the same session as the calling
   process.  setpgid() sets errno to EPERM.

-> pgid does  not match the process identifier of  the process indicated by
   pid, and the call process's  session has no process with a process-group
   identifier that equals pgid. setpgid() sets errno to EPERM.

-> pid does not match the process identifier of the calling process or of a
   child process of the calling process.  setpgid() sets errno to ESRCH.

See Also

libc,
unistd.h
POSIX Standard, §4.3.3