xref: /original-bsd/lib/libc/sys/setsid.2 (revision c3e32dec)
1.\" Copyright (c) 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"	@(#)setsid.2	8.1 (Berkeley) 06/04/93
7.\"
8.Dd ""
9.Dt SETSID 2
10.Os
11.Sh NAME
12.Nm setsid
13.Nd create session and set process group ID
14.Sh SYNOPSIS
15.Fd #include <sys/types.h>
16.Ft pid_t
17.Fn setsid "void"
18.Sh DESCRIPTION
19The
20.Nm setsid
21function creates a new session.
22The calling process is the session leader of the new session, is the
23process group leader of a new process group and has no controlling
24terminal.
25The calling process is the only process in either the session or the
26process group.
27.Pp
28Upon successful completion, the
29.Nm setsid
30function returns the value of the process group ID of the new process
31group, which is the same as the process ID of the calling process.
32.Sh ERRORS
33If an error occurs,
34.Nm setsid
35returns -1 and the global variable
36.Va errno
37is set to indicate the error, as follows:
38.Bl -tag -width Er
39.It Bq Er EPERM
40The calling process is already a process group leader, or the process
41group ID of a process other than the calling process matches the process
42ID of the calling process.
43.El
44.Sh SEE ALSO
45.Xr setpgid 3 ,
46.Xr tcgetpgrp 3 ,
47.Xr tcsetpgrp 3
48.Sh STANDARDS
49The
50.Nm setsid
51function is expected to be compliant with the
52.St -p1003.1-88
53specification.
54