setsid(2)
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 will create a new session. The calling process will be the session leader of this new session, will be the process group leader of a new process group, and will not have a controlling terminal. The process group ID of the calling process will set to the process ID of the calling process. The calling process will be the only process in the new process group and the only process in the new session.
NOTES
The only way for a session to allocate a controlling terminal is for the session leader (which must not already have a controlling terminal) to open a terminal device that is not already associated with any session, without using the O_NOCTTY option to open(). The effect is that the processes in a session may have at most one controlling terminal, and a terminal may have at most one controlling process, which must be a session leader.
RETURN VALUE
Upon successful completion, the setsid() function returns a value of the process group ID of the calling process.
ERRORS
If any of the following conditions occur, the setsid() function shall return −1 and set errno to the corresponding value:
[EPERM] The calling process is already a process group leader or the process group ID of a process other than the calling process matches the process ID of the calling process.
SEE ALSO
exec(2), exit(2), fork(2), getpid(2), kill(2), open(2), setpgid(2), sigaction(2)
CX/UX Programmer’s Reference Manual