xref: /openbsd/lib/libc/sys/getsid.2 (revision 73471bf0)
1.\"	$OpenBSD: getsid.2,v 1.12 2015/09/10 17:55:21 schwarze Exp $
2.\"
3.\" Copyright (c) 1997 Peter Wemm <peter@freebsd.org>
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\"
27.Dd $Mdocdate: September 10 2015 $
28.Dt GETSID 2
29.Os
30.Sh NAME
31.Nm getsid
32.Nd get process session
33.Sh SYNOPSIS
34.In unistd.h
35.Ft pid_t
36.Fn getsid "pid_t pid"
37.Sh DESCRIPTION
38The session ID of the process identified by
39.Fa pid
40is returned by
41.Fn getsid .
42If
43.Fa pid
44is zero,
45.Fn getsid
46returns the session ID of the current process.
47.Sh RETURN VALUES
48Upon successful completion, the function
49.Fn getsid
50returns the session ID of
51the specified process; otherwise, it returns a value of \-1 and
52sets
53.Va errno
54to indicate an error.
55.Sh ERRORS
56.Fn getsid
57will succeed unless:
58.Bl -tag -width Er
59.It Bq Er EPERM
60The current process and the process
61.Fa pid
62are not in the same session.
63.It Bq Er ESRCH
64There is no process with a process ID equal to
65.Fa pid .
66.El
67.Sh SEE ALSO
68.Xr getpgid 2 ,
69.Xr getpgrp 2 ,
70.Xr setpgid 2 ,
71.Xr setsid 2 ,
72.Xr termios 4
73.Sh STANDARDS
74.Fn getsid
75conforms to
76.St -p1003.1-2008 .
77.Sh HISTORY
78The
79.Fn getsid
80function call is derived from its usage in
81.At V ,
82and is mandated by
83.St -xpg4 .
84