xref: /freebsd/lib/libc/gen/tcsetsid.3 (revision 46b303e83d53aaff3e408c9695d45d3fa6a42b7a)
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.\"
2546b303e8SEd Schouten.\" $FreeBSD$
2646b303e8SEd Schouten.\"
2746b303e8SEd Schouten.Dd May 4, 2009
2846b303e8SEd Schouten.Dt TCSETSID 3
2946b303e8SEd Schouten.Os
3046b303e8SEd Schouten.Sh NAME
3146b303e8SEd Schouten.Nm tcsetsid
3246b303e8SEd Schouten.Nd set session ID associated with a controlling terminal
3346b303e8SEd Schouten.Sh LIBRARY
3446b303e8SEd Schouten.Lb libc
3546b303e8SEd Schouten.Sh SYNOPSIS
3646b303e8SEd Schouten.In sys/types.h
3746b303e8SEd Schouten.In termios.h
3846b303e8SEd Schouten.Ft int
3946b303e8SEd Schouten.Fn tcsetsid "int fd" "pid_t pid"
4046b303e8SEd Schouten.Sh DESCRIPTION
4146b303e8SEd SchoutenThe
4246b303e8SEd Schouten.Fn tcsetsid
4346b303e8SEd Schoutenfunction sets associates a session identified by
4446b303e8SEd Schouten.Fa pid
4546b303e8SEd Schoutenwith a controlling terminal specified by
4646b303e8SEd Schouten.Fa fd .
4746b303e8SEd Schouten.Pp
4846b303e8SEd SchoutenThis implementation only allows the controlling terminal to be changed
4946b303e8SEd Schoutenby the session leader itself.
5046b303e8SEd SchoutenThis implies that
5146b303e8SEd Schouten.Fa pid
5246b303e8SEd Schoutenalways has to be equal to the process ID.
5346b303e8SEd Schouten.Pp
5446b303e8SEd SchoutenIt is unsupported to associate with a terminal that already has an
5546b303e8SEd Schoutenassociated session.
5646b303e8SEd SchoutenConversely, it is also unsupported to associate to a terminal when
5746b303e8SEd Schoutenthe session is already associated with a different terminal.
5846b303e8SEd Schouten.Sh ERRORS
5946b303e8SEd SchoutenIf an error occurs,
6046b303e8SEd Schouten.Fn tcsetsid
6146b303e8SEd Schoutenreturns -1 and the global variable
6246b303e8SEd Schouten.Va errno
6346b303e8SEd Schoutenis set to indicate the error, as follows:
6446b303e8SEd Schouten.Bl -tag -width Er
6546b303e8SEd Schouten.It Bq Er EBADF
6646b303e8SEd SchoutenThe
6746b303e8SEd Schouten.Fa fd
6846b303e8SEd Schoutenargument is not a valid file descriptor.
6946b303e8SEd Schouten.It Bq Er ENOTTY
7046b303e8SEd SchoutenThe file descriptor represented by
7146b303e8SEd Schouten.Fa fd
7246b303e8SEd Schoutenis not a terminal.
7346b303e8SEd Schouten.It Bq Er EINVAL
7446b303e8SEd SchoutenThe
7546b303e8SEd Schouten.Fa pid
7646b303e8SEd Schoutenargument is not equal to the session ID of the calling process.
7746b303e8SEd Schouten.It Bq Er EPERM
7846b303e8SEd SchoutenThe calling process is not a session leader.
7946b303e8SEd Schouten.It Bq Er EPERM
8046b303e8SEd SchoutenThe session already has an associated terminal or the terminal already
8146b303e8SEd Schoutenhas an associated session.
8246b303e8SEd Schouten.El
8346b303e8SEd Schouten.Sh SEE ALSO
8446b303e8SEd Schouten.Xr getsid 2 ,
8546b303e8SEd Schouten.Xr setsid 2 ,
8646b303e8SEd Schouten.Xr tcgetpgrp 3 ,
8746b303e8SEd Schouten.Xr tcgetsid 3
8846b303e8SEd Schouten.Sh HISTORY
8946b303e8SEd SchoutenA
9046b303e8SEd Schouten.Fn tcsetsid
9146b303e8SEd Schoutenfunction first appeared in QNX.
9246b303e8SEd SchoutenIt does not comply to any standard.
93