setsid - create session and set process group ID
If the calling process is not a process group leader, the setsid()
function creates a new session. The calling process 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 control-
ling terminal, setsid() 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 process. The calling
process is the only process in the new process group and the only
process in the new session.
setsid() returns the process group ID of the calling process on suc-
cess. On failure, it returns -1 and sets errno to indicate the error.
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.
execve(2V), exit(2V), fork(2V), getpid(2V), getpgrp(2V), kill(2V),
21 January 1990 SETSID(2V)