1SETSID(2)                  Linux Programmer's Manual                 SETSID(2)
2
3
4

NAME

6       setsid - creates a session and sets the process group ID
7

SYNOPSIS

9       #include <unistd.h>
10
11       pid_t setsid(void);
12

DESCRIPTION

14       setsid()  creates a new session if the calling process is not a process
15       group leader.  The calling process is the leader of  the  new  session,
16       the  process group leader of the new process group, and has no control‐
17       ling tty.  The process group ID and session ID of the  calling  process
18       are set to the PID of the calling process.  The calling process will be
19       the only process in this new process group and in this new session.
20

RETURN VALUE

22       The session ID of the calling process.
23

ERRORS

25       On error, -1 is returned, and errno is set.  The only error  which  can
26       happen  is  EPERM.  It  is  returned  when  the process group ID of any
27       process equals the PID of the calling  process.  Thus,  in  particular,
28       setsid()  fails  if  the  calling  process  is  already a process group
29       leader.
30

NOTES

32       A child created via fork(2) inherits its parent's session ID.  The ses‐
33       sion ID is preserved across an execve(2).
34
35       A  process group leader is a process with process group ID equal to its
36       PID. In order to be sure that setsid() will succeed, fork() and exit(),
37       and have the child do setsid().
38

CONFORMING TO

40       SVr4, POSIX.1-2001.
41

SEE ALSO

43       setpgid(2), setpgrp(2), tcgetsid(3)
44
45
46
47Linux 1.0.0                       1994-08-27                         SETSID(2)
Impressum