1 .\" Copyright (c) OpenBSD Group
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" Converted into a manpage again by Martin Schulze <joey@infodrom.org>
30 .\" Added -lutil remark, 030718
32 .TH OPENPTY 3 "2003-07-18" "BSD" "Linux Programmer's Manual"
34 openpty, login_tty, forkpty \- tty utility functions
37 \ /* for openpty and forkpty */
42 .BI "int openpty(int *" amaster ", int *" aslave ", char *" name ", struct termios *" termp ", struct winsize * " winp );
44 .BI "int login_tty(int " fd );
46 .BI "pid_t forkpty(int *" amaster ", char *" name ", struct termios *" termp ", struct winsize *" winp );
52 function finds an available pseudo-terminal and returns file descriptors
53 for the master and slave in
59 is not NULL, the filename of the slave is returned in
63 is not NULL, the terminal parameters of the slave will be set to the
68 is not NULL, the window size of the slave will be set to the values in
73 function prepares for a login on the tty
75 (which may be a real tty device, or the slave of a pseudo-terminal as
78 by creating a new session, making
80 the controlling terminal for the current process, setting
82 to be the standard input, output, and error streams of the current
93 to create a new process operating in a pseudo-terminal. The file
94 descriptor of the master side of the pseudo-terminal is returned in
96 and the filename of the slave in
98 if it is not NULL. The
102 parameters, if not NULL,
103 will determine the terminal attributes and window size of the slave
104 side of the pseudo-terminal.
111 is not successful, \-1 is returned and
113 is set to indicate the error. Otherwise,
116 and the child process of
118 return 0, and the parent process of
120 returns the process ID of the child process.
126 There are no available ttys.
133 to the controlling terminal of the current process.
142 These functions are included in libutil, hence you'll need to add
144 to your compiler command line.
146 .I /dev/[pt]ty[pqrstuwxyzabcdePQRST][0123456789abcdef]
148 These are BSD functions, present in libc5 and glibc2.
150 Nobody knows how much space should be reserved for