xref: /freebsd/share/man/man4/pts.4 (revision 195ebc7e9e4b129de810833791a19dfb4349d6a9)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
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. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)pty.4	8.2 (Berkeley) 11/30/93
33.\" $FreeBSD$
34.\"
35.Dd August 20, 2008
36.Dt PTS 4
37.Os
38.Sh NAME
39.Nm pts
40.Nd pseudo-terminal driver
41.Sh DESCRIPTION
42The
43.Nm
44driver provides support for a device-pair termed a
45.Em pseudo-terminal .
46A pseudo-terminal is a pair of character devices, a
47.Em master
48device and a
49.Em slave
50device.
51The slave device provides to a process an interface identical
52to that described in
53.Xr tty 4 .
54However, whereas all other devices which provide the
55interface described in
56.Xr tty 4
57have a hardware device of some sort behind them, the slave
58device has, instead, another process manipulating
59it through the master half of the pseudo-terminal.
60That is, anything written on the master device is
61given to the slave device as input and anything written
62on the slave device is presented as input on the master
63device.
64.Pp
65The following
66.Xr ioctl 2
67calls apply only to pseudo-terminals:
68.Bl -tag -width TIOCPTMASTER
69.It Dv TIOCPKT
70Enable/disable
71.Em packet
72mode.
73Packet mode is enabled by specifying (by reference)
74a nonzero parameter and disabled by specifying (by reference)
75a zero parameter.
76When applied to the master side of a pseudo-terminal, each subsequent
77.Xr read 2
78from the terminal will return data written on the slave part of
79the pseudo-terminal preceded by a zero byte (symbolically
80defined as
81.Dv TIOCPKT_DATA ) ,
82or a single byte reflecting control
83status information.
84In the latter case, the byte is an inclusive-or
85of zero or more of the bits:
86.Bl -tag -width TIOCPKT_FLUSHWRITE
87.It Dv TIOCPKT_FLUSHREAD
88whenever the read queue for the terminal is flushed.
89.It Dv TIOCPKT_FLUSHWRITE
90whenever the write queue for the terminal is flushed.
91.It Dv TIOCPKT_STOP
92whenever output to the terminal is stopped a la
93.Ql ^S .
94.It Dv TIOCPKT_START
95whenever output to the terminal is restarted.
96.It Dv TIOCPKT_DOSTOP
97whenever
98.Dv VSTOP
99is
100.Ql ^S
101and
102.Dv VSTART
103is
104.Ql ^Q .
105.It Dv TIOCPKT_NOSTOP
106whenever the start and stop characters are not
107.Ql ^S/^Q .
108.El
109.Pp
110While this mode is in use, the presence of control status information
111to be read from the master side may be detected by a
112.Xr select 2
113for exceptional conditions.
114.Pp
115This mode is used by
116.Xr rlogin 1
117and
118.Xr rlogind 8
119to implement a remote-echoed, locally
120.Ql ^S/^Q
121flow-controlled
122remote login with proper back-flushing of output; it can be
123used by other similar programs.
124.It Dv TIOCGPTN
125Obtain device unit number, which can be used to generate the filename of
126the pseudo-terminal slave device. This
127.Xr ioctl 2
128should not be used directly. Instead, the
129.Xr ptsname 3
130function should be used.
131.It Dv TIOCPTMASTER
132Determine whether the file descriptor is pointing to a pseudo-terminal
133master device.
134This
135.Xr ioctl 2
136should not be used directly. It is used to implement routines like
137.Xr grantpt 3 .
138.El
139.Pp
140The maximum number of pseudo-terminals is limited to 1000.
141It is not possible to use more than 1000 pseudo-terminals, as all software
142which use
143.Xr utmp 5
144will not be able to handle pseudo-terminals with number superior to 999.
145.Sh FILES
146The files used by this
147pseudo-terminals implementation are:
148.Pp
149.Bl -tag -width ".Pa /dev/pts/[num]"
150.It Pa /dev/ptmx
151Control device, returns a file descriptor to a new master pseudo-terminal
152when opened. This device should not be opened directly. It's only
153available for binary compatibility. New devices should only be created
154though
155.Xr posix_openpt 2 .
156.It Pa /dev/pts/[num]
157Pseudo-terminal slave devices.
158.El
159.Sh SYSCTL VARIABLES
160The following
161.Xr sysctl 8
162variables can be used to modify or monitor
163.Nm
164behavior.
165.Bl -tag -width indent
166.It Va kern.pts_maxdev
167Highest pseudo-terminal unit number to be allocated.
168Because
169.Xr utmp 5
170is restricted to an 8-byte line name size,
171.Nm
172will not create any pseudo-terminals with a unit number above 999 by
173default.
174After increasing
175.Dv UT_LINESIZE ,
176this variable can be changed to allow more than 1000 pseudo-terminals to
177be allocated simultaneously.
178.El
179.Sh DIAGNOSTICS
180None.
181.Sh SEE ALSO
182.Xr grantpt 3 ,
183.Xr posix_openpt 2 ,
184.Xr ptsname 3 ,
185.Xr pty 4 ,
186.Xr tty 4
187.Sh HISTORY
188A
189pseudo-terminal driver appeared in
190.Bx 4.2 .
191In
192.Fx 8.0 ,
193it was replaced with the
194.Nm
195driver.
196