SETSID(2) BSD SETSID(2)
NAME
setsid - set session and set process group ID
SYNOPSIS
#include <sys/types.h>
pid_t setsid(void);
DESCRIPTION
The setsid function creates a new session when the calling process is not
a process group leader. Upon return, the calling process becomes the
session leader of this session, becomes the process leader of the new
process group, and has no controlling terminal.
The process group ID of the calling process is set equal to its process
ID. The calling process becomes the only process in the new process
group and the only process in the new session.
DIAGNOSTICS
Upon successful completion, the value of the new process group ID is
returned. Otherwise, a value of -1 is returned and errno is set to
indicate the error.
ERRORS
setsid fails if:
[EPERM] The calling process is already the 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
open(2), _exit(2), fork(2), kill(2), sigaction(2), getpid(2), exec(2),
setpgid(2), </sys/types.h>