


SETPGID(2V)               SYSTEM CALLS                SETPGID(2V)



NAME
     setpgid - set process group ID for job control

SYNOPSIS
     #include <sys/types.h>

     int setpgid (pid, pgid)
     pid_t pid, pgid;

DESCRIPTION
     setpgid() is used to either join an existing  process  group
     or create a new process group within the session of the cal-
     ling process (see NOTES). The process group ID of a  session
     leader  does  not  change.   Upon successful completion, the
     process group ID of the  process  with  a  process  ID  that
     matches  _p_i_d  is  set to _p_g_i_d.  As a special case, if _p_i_d is
     zero, the process ID of the calling process is used.   Also,
     if  _p_g_i_d is zero, the process ID of the process indicated by
     _p_i_d is used.

RETURN VALUES
     setpgid() returns:

     0    on success.

     -1   on failure and sets errno to indicate the error.

ERRORS
     EACCES         The value of _p_i_d matches the process ID of  a
                    child  process of the calling process and the
                    child process has successfully  executed  one
                    of the exec() functions.

     EINVAL         The value of _p_g_i_d is less  than  zero  or  is
                    greater  than  MAXPID, the maximum process ID
                    as defined in <sys/param.h>.

     EPERM          The process indicated by  _p_i_d  is  a  session
                    leader.   The  value  of  _p_i_d  is  valid  but
                    matches the process ID of a child process  of
                    the  calling process and the child process is
                    not in the same session as the  calling  pro-
                    cess.   The  value of _p_g_i_d does not match the
                    process ID of the process  indicated  by  _p_i_d
                    and  there is no process with a process group
                    ID that matches the value of _p_g_i_d in the same
                    session as the calling process.

     ESRCH          _p_i_d does not match the  PID  of  the  calling
                    process  or the PID of a child of the calling
                    process.




Sun Release 4.1   Last change: 21 January 1990                  1






SETPGID(2V)               SYSTEM CALLS                SETPGID(2V)



SEE ALSO
     getpgrp(2V), execve(2V), setsid(2V), tcgetpgrp(3V)

NOTES
     For   setpgid()    to    behave    as    described    above,
     {_POSIX_JOB_CONTROL}  must  be  in effect (see sysconf(2V)).
     {_POSIX_JOB_CONTROL} is always in effect on  SunOS  systems,
     but  for  portability, applications should call sysconf() to
     determine whether {_POSIX_JOB_CONTROL} is in effect for  the
     current system.













































Sun Release 4.1   Last change: 21 January 1990                  2



