1 .\" Copyright (c) OpenBSD Group
2 .\" All rights reserved.
4 .\" %%%LICENSE_START(BSD_3_CLAUSE_UCB)
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
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 .\" 3. Neither the name of the University nor the names of its contributors
14 .\" may be used to endorse or promote products derived from this software
15 .\" without specific prior written permission.
17 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" Converted into a manpage again by Martin Schulze <joey@infodrom.org>
32 .\" Added -lutil remark, 030718
34 .TH OPENPTY 3 2021-03-22 "GNU" "Linux Programmer's Manual"
36 openpty, login_tty, forkpty \- terminal utility functions
41 .BI "int openpty(int *" amaster ", int *" aslave ", char *" name ,
42 .BI " const struct termios *" termp ,
43 .BI " const struct winsize *" winp );
44 .BI "pid_t forkpty(int *" amaster ", char *" name ,
45 .BI " const struct termios *" termp ,
46 .BI " const struct winsize *" winp );
50 .BI "int login_tty(int " fd );
52 Link with \fI\-lutil\fP.
57 function finds an available pseudoterminal and returns file descriptors
58 for the master and slave in
64 is not NULL, the filename of the slave is returned in
68 is not NULL, the terminal parameters of the slave will be set to the
73 is not NULL, the window size of the slave will be set to the values in
78 function prepares for a login on the terminal
79 referred to by the file descriptor
81 (which may be a real terminal device, or the slave of a pseudoterminal as
84 by creating a new session, making
86 the controlling terminal for the calling process, setting
88 to be the standard input, output, and error streams of the current
99 to create a new process operating in a pseudoterminal.
100 A file descriptor referring to
101 master side of the pseudoterminal is returned in
105 is not NULL, the buffer it points to is used to return the
106 filename of the slave.
111 arguments, if not NULL,
112 will determine the terminal attributes and window size of the slave
113 side of the pseudoterminal.
120 is not successful, \-1 is returned and
122 is set to indicate the error.
126 and the child process of
128 return 0, and the parent process of
130 returns the process ID of the child process.
136 There are no available terminals.
143 to the controlling terminal of the calling process.
152 For an explanation of the terms used in this section, see
160 Interface Attribute Value
164 T} Thread safety MT-Safe locale
167 T} Thread safety MT-Unsafe race:ttyname
173 These are BSD functions, present in glibc.
174 They are not standardized in POSIX.
178 modifiers were added to the structure pointer arguments of
184 In versions of glibc before 2.0.92,
186 returns file descriptors for a BSD pseudoterminal pair;
188 it first attempts to open a UNIX 98 pseudoterminal pair,
189 and falls back to opening a BSD pseudoterminal pair if that fails.
191 Nobody knows how much space should be reserved for