


SETSID(2V)                SYSTEM CALLS                 SETSID(2V)



NAME
     setsid - create session and set process group ID

SYNOPSIS
     #include <sys/types.h>

     pid_t setsid()

DESCRIPTION
     If the calling process is not a process  group  leader,  the
     setsid()  function  creates a new session.  The calling pro-
     cess is the session leader of this new session, the  process
     group  leader of a new process group, and has no controlling
     terminal.  If the process had a controlling  terminal,  set-
     sid()  breaks  the  association between the process and that
     controlling terminal.  The process group ID of  the  calling
     process  is  set equal to the process ID of the calling pro-
     cess.  The calling process is the only process  in  the  new
     process group and the only process in the new session.

RETURN VALUES
     setsid() returns the process group ID of the calling process
     on  success.   On  failure,  it returns -1 and sets errno to
     indicate the error.

ERRORS
     If any of the following conditions occur,  setsid()  returns
     -1 and sets errno to the corresponding value:

     EPERM          The calling  process  is  already  a  process
                    group leader.

                    The process ID of the calling process  equals
                    the process group ID of a different process.

SEE ALSO
     execve(2V),  exit(2V),  fork(2V),  getpid(2V),  getpgrp(2V),
     kill(2V), setpgid(2V), sigaction(3V)

















Sun Release 4.1   Last change: 21 January 1990                  1



