sseettppggiidd() -- System Call (libc)

Set the process-group identifier
#iinncclluuddee <ssyyss/ttyyppeess.hh>
#iinncclluuddee <uunniissttdd.hh>
iinntt sseettppggiidd(_p_i_d, _p_g_i_d)
ppiidd_tt _p_i_d, _p_g_i_d;

sseettppggiidd() sets  to _p_g_i_d  the process-group  identifier of the  process with
identifier _p_i_d.  If _p_g_i_d  equals _p_i_d,  the process becomes  a process-group
leader.  If  _p_g_i_d does not  equal _p_i_d, the  process becomes a  member of an
existing process group.

If _p_i_d  equals zero, sseettppggiidd()  uses the process identifier  of the calling
process.   If _p_g_i_d  equals zero,  the  process specified  by _p_i_d  becomes a
process-group leader.

If all goes well, sseettppggiidd() returns a value of zero.  Otherwise, it returns
-1  and sets  eerrrrnnoo  to an  appropriate  value.  sseettppggiidd()  if  any of  the
following are true:

-> _p_i_d matches  the process  identifier of a  child process of  the calling
   process,  and that  child process  has  successfully executed  an eexxeecc()
   function.  sseettppggiidd() sets eerrrrnnoo to EEAACCCCEESS.

-> _p_g_i_d is  less than zero or  greater than or equal  to PPIIDD_MMAAXX. sseettppggiidd()
   sets eerrrrnnoo to EEIINNVVAALL.

-> The calling process has a controlling terminal that does not support job
   control.  sseettppggiidd() sets eerrrrnnoo to EEIINNVVAALL.

-> The process  identified by _p_i_d argument is  a session leader.  sseettppggiidd()
   sets eerrrrnnoo to EEPPEERRMM.

-> _p_i_d  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.  sseettppggiidd() sets eerrrrnnoo to EEPPEERRMM.

-> _p_g_i_d does  not match the process identifier of  the process indicated by
   _p_i_d, and the call process's  session has no process with a process-group
   identifier that equals _p_g_i_d. sseettppggiidd() sets eerrrrnnoo to EEPPEERRMM.

-> _p_i_d does not match the process identifier of the calling process or of a
   child process of the calling process.  sseettppggiidd() sets eerrrrnnoo to EESSRRCCHH.

_S_e_e _A_l_s_o
lliibbcc, uunniissttdd.hh
POSIX Standard, section 4.3.3
