xref: /freebsd/lib/libc/gen/tcsetsid.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
146b303e8SEd Schouten.\" Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org>
246b303e8SEd Schouten.\" All rights reserved.
346b303e8SEd Schouten.\"
446b303e8SEd Schouten.\" Redistribution and use in source and binary forms, with or without
546b303e8SEd Schouten.\" modification, are permitted provided that the following conditions
646b303e8SEd Schouten.\" are met:
746b303e8SEd Schouten.\" 1. Redistributions of source code must retain the above copyright
846b303e8SEd Schouten.\"    notice, this list of conditions and the following disclaimer.
946b303e8SEd Schouten.\" 2. Redistributions in binary form must reproduce the above copyright
1046b303e8SEd Schouten.\"    notice, this list of conditions and the following disclaimer in the
1146b303e8SEd Schouten.\"    documentation and/or other materials provided with the distribution.
1246b303e8SEd Schouten.\"
1346b303e8SEd Schouten.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1446b303e8SEd Schouten.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1546b303e8SEd Schouten.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1646b303e8SEd Schouten.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1746b303e8SEd Schouten.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1846b303e8SEd Schouten.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1946b303e8SEd Schouten.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2046b303e8SEd Schouten.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2146b303e8SEd Schouten.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2246b303e8SEd Schouten.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2346b303e8SEd Schouten.\" SUCH DAMAGE.
2446b303e8SEd Schouten.\"
25*a6d40b0aSGuilherme Janczak.Dd November 28, 2022
2646b303e8SEd Schouten.Dt TCSETSID 3
2746b303e8SEd Schouten.Os
2846b303e8SEd Schouten.Sh NAME
2946b303e8SEd Schouten.Nm tcsetsid
3046b303e8SEd Schouten.Nd set session ID associated with a controlling terminal
3146b303e8SEd Schouten.Sh LIBRARY
3246b303e8SEd Schouten.Lb libc
3346b303e8SEd Schouten.Sh SYNOPSIS
3446b303e8SEd Schouten.In termios.h
3546b303e8SEd Schouten.Ft int
3646b303e8SEd Schouten.Fn tcsetsid "int fd" "pid_t pid"
3746b303e8SEd Schouten.Sh DESCRIPTION
3846b303e8SEd SchoutenThe
3946b303e8SEd Schouten.Fn tcsetsid
4046b303e8SEd Schoutenfunction sets associates a session identified by
4146b303e8SEd Schouten.Fa pid
4246b303e8SEd Schoutenwith a controlling terminal specified by
4346b303e8SEd Schouten.Fa fd .
4446b303e8SEd Schouten.Pp
4546b303e8SEd SchoutenThis implementation only allows the controlling terminal to be changed
4646b303e8SEd Schoutenby the session leader itself.
4746b303e8SEd SchoutenThis implies that
4846b303e8SEd Schouten.Fa pid
4946b303e8SEd Schoutenalways has to be equal to the process ID.
5046b303e8SEd Schouten.Pp
5146b303e8SEd SchoutenIt is unsupported to associate with a terminal that already has an
5246b303e8SEd Schoutenassociated session.
5346b303e8SEd SchoutenConversely, it is also unsupported to associate to a terminal when
5446b303e8SEd Schoutenthe session is already associated with a different terminal.
5546b303e8SEd Schouten.Sh ERRORS
5646b303e8SEd SchoutenIf an error occurs,
5746b303e8SEd Schouten.Fn tcsetsid
5846b303e8SEd Schoutenreturns -1 and the global variable
5946b303e8SEd Schouten.Va errno
6046b303e8SEd Schoutenis set to indicate the error, as follows:
6146b303e8SEd Schouten.Bl -tag -width Er
6246b303e8SEd Schouten.It Bq Er EBADF
6346b303e8SEd SchoutenThe
6446b303e8SEd Schouten.Fa fd
6546b303e8SEd Schoutenargument is not a valid file descriptor.
6646b303e8SEd Schouten.It Bq Er ENOTTY
6746b303e8SEd SchoutenThe file descriptor represented by
6846b303e8SEd Schouten.Fa fd
6946b303e8SEd Schoutenis not a terminal.
7046b303e8SEd Schouten.It Bq Er EINVAL
7146b303e8SEd SchoutenThe
7246b303e8SEd Schouten.Fa pid
7346b303e8SEd Schoutenargument is not equal to the session ID of the calling process.
7446b303e8SEd Schouten.It Bq Er EPERM
7546b303e8SEd SchoutenThe calling process is not a session leader.
7646b303e8SEd Schouten.It Bq Er EPERM
7746b303e8SEd SchoutenThe session already has an associated terminal or the terminal already
7846b303e8SEd Schoutenhas an associated session.
7946b303e8SEd Schouten.El
8046b303e8SEd Schouten.Sh SEE ALSO
8146b303e8SEd Schouten.Xr getsid 2 ,
8246b303e8SEd Schouten.Xr setsid 2 ,
8346b303e8SEd Schouten.Xr tcgetpgrp 3 ,
8446b303e8SEd Schouten.Xr tcgetsid 3
8546b303e8SEd Schouten.Sh HISTORY
8646b303e8SEd SchoutenA
8746b303e8SEd Schouten.Fn tcsetsid
8846b303e8SEd Schoutenfunction first appeared in QNX.
8946b303e8SEd SchoutenIt does not comply to any standard.
90