setsid(2)
NAME
setsid − POSIX create session and set process group ID
SYNTAX
#include <sys/types.h>
pid_t
setsid()
DESCRIPTION
The setsid system call creates a new session if the calling process is not a process group leader. The calling process is the session leader of the new session, the process group leader of the new process group and does not have a controlling terminal. The process group ID of the calling process is set equal to the process ID of the calling process.
RETURN VALUE
Upon successful completion the setsid system call returns the value of the process group ID of the calling process. If the setsid system call fails, −1 is returned and the global variable errno indicates the reason.
DIAGNOSTICS
The setsid system call will fail and a new session will not be created if one of the following occur:
[EPERM] The calling process is already a process group leader. The process group ID of a process other than the calling process matches the process ID of the calling process.