Deleted Added
full compact
pty.4 (169933) pty.4 (181905)
1.\" Copyright (c) 1983, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
1.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
2.\" All rights reserved.
3.\"
3.\"
4.\" Portions of this software were developed under sponsorship from Snow
5.\" B.V., the Netherlands.
6.\"
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.
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" 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.\"
15.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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.\"
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
26.\" SUCH DAMAGE.
27.\"
32.\" @(#)pty.4 8.2 (Berkeley) 11/30/93
33.\" $FreeBSD: head/share/man/man4/pty.4 169933 2007-05-24 09:43:41Z yar $
28.\" $FreeBSD: head/share/man/man4/pty.4 181905 2008-08-20 08:31:58Z ed $
34.\"
29.\"
35.Dd November 30, 1993
30.Dd August 20, 2008
36.Dt PTY 4
37.Os
38.Sh NAME
39.Nm pty
31.Dt PTY 4
32.Os
33.Sh NAME
34.Nm pty
40.Nd pseudo terminal driver
35.Nd BSD-style compatibility pseudo-terminal driver
41.Sh SYNOPSIS
42.Cd "device pty"
43.Sh DESCRIPTION
44The
45.Nm
36.Sh SYNOPSIS
37.Cd "device pty"
38.Sh DESCRIPTION
39The
40.Nm
46driver provides support for a device-pair termed a
47.Em pseudo terminal .
48A pseudo terminal is a pair of character devices, a
49.Em master
50device and a
51.Em slave
52device.
53The slave device provides to a process an interface identical
54to that described in
55.Xr tty 4 .
56However, whereas all other devices which provide the
57interface described in
58.Xr tty 4
59have a hardware device of some sort behind them, the slave
60device has, instead, another process manipulating
61it through the master half of the pseudo terminal.
62That is, anything written on the master device is
63given to the slave device as input and anything written
64on the slave device is presented as input on the master
65device.
41driver provides support for the traditional BSD naming scheme that was
42used for accessing pseudo-terminals.
43When the device
44.Pa /dev/ptyXX
45is being opened, a new terminal shall be created with the
46.Xr pts 4
47driver.
48A device node for this terminal shall be created, which has the name
49.Pa /dev/ttyXX .
66.Pp
50.Pp
67The following
68.Xr ioctl 2
69calls apply only to pseudo terminals:
70.Bl -tag -width TIOCREMOTE
71.It Dv TIOCSTOP
72Stops output to a terminal (e.g.\& like typing
73.Ql ^S ) .
74Takes
75no parameter.
76.It Dv TIOCSTART
77Restarts output (stopped by
78.Dv TIOCSTOP
79or by typing
80.Ql ^S ) .
81Takes no parameter.
82.It Dv TIOCPKT
83Enable/disable
84.Em packet
85mode.
86Packet mode is enabled by specifying (by reference)
87a nonzero parameter and disabled by specifying (by reference)
88a zero parameter.
89When applied to the master side of a pseudo terminal, each subsequent
90.Xr read 2
91from the terminal will return data written on the slave part of
92the pseudo terminal preceded by a zero byte (symbolically
93defined as
94.Dv TIOCPKT_DATA ) ,
95or a single byte reflecting control
96status information.
97In the latter case, the byte is an inclusive-or
98of zero or more of the bits:
99.Bl -tag -width TIOCPKT_FLUSHWRITE
100.It Dv TIOCPKT_FLUSHREAD
101whenever the read queue for the terminal is flushed.
102.It Dv TIOCPKT_FLUSHWRITE
103whenever the write queue for the terminal is flushed.
104.It Dv TIOCPKT_STOP
105whenever output to the terminal is stopped a la
106.Ql ^S .
107.It Dv TIOCPKT_START
108whenever output to the terminal is restarted.
109.It Dv TIOCPKT_DOSTOP
110whenever
111.Em t_stopc
112is
113.Ql ^S
114and
115.Em t_startc
116is
117.Ql ^Q .
118.It Dv TIOCPKT_NOSTOP
119whenever the start and stop characters are not
120.Ql ^S/^Q .
121.El
122.Pp
123While this mode is in use, the presence of control status information
124to be read from the master side may be detected by a
125.Xr select 2
126for exceptional conditions.
127.Pp
128This mode is used by
129.Xr rlogin 1
130and
131.Xr rlogind 8
132to implement a remote-echoed, locally
133.Ql ^S/^Q
134flow-controlled
135remote login with proper back-flushing of output; it can be
136used by other similar programs.
137.It Dv TIOCUCNTL
138Enable/disable a mode that allows a small number of simple user
139.Xr ioctl 2
140commands to be passed through the pseudo-terminal,
141using a protocol similar to that of
142.Dv TIOCPKT .
143The
144.Dv TIOCUCNTL
145and
146.Dv TIOCPKT
147modes are mutually exclusive.
148This mode is enabled from the master side of a pseudo terminal
149by specifying (by reference)
150a nonzero parameter and disabled by specifying (by reference)
151a zero parameter.
152Each subsequent
153.Xr read 2
154from the master side will return data written on the slave part of
155the pseudo terminal preceded by a zero byte,
156or a single byte reflecting a user control operation on the slave side.
157A user control command consists of a special
158.Xr ioctl 2
159operation with no data; the command is given as
160.Dv UIOCCMD Ns (n) ,
161where
162.Ar n
163is a number in the range 1-255.
164The operation value
165.Ar n
166will be received as a single byte on the next
167.Xr read 2
168from the master side.
169The
170.Xr ioctl 2
171.Dv UIOCCMD Ns (0)
172is a no-op that may be used to probe for
173the existence of this facility.
174As with
175.Dv TIOCPKT
176mode, command operations may be detected with a
177.Xr select 2
178for exceptional conditions.
179.El
180.Pp
181There is currently two
182.Nm
183systems available: the original
184.Bx Nm ,
185and a
186SysVR4 pts-like implementation.
187It is possible to switch between the two implementations by setting the
188.Va kern.pts.enable
189sysctl.
190Setting it to 0 will use the
191.Bx Nm ,
192to non-zero the pts implementation.
193It defaults to 0.
194It is possible to set the maximum number of ptys
195which can be allocated at the same time with the
196.Va kern.pts.max
197sysctl.
198It defaults to 1000.
199It is not recommended to use more than 1000 pseudo-terminals, as all software
200which use
201.Xr utmp 5
202will not be able to handle pseudo-terminals with number superior to 999.
203.Pp
204The pts implementation also supports the
205.Dv TIOCGPTN
206.Xr ioctl 2
207call, which takes a pointer to an
208.Vt "unsigned int"
209as a parameter and provides the
210number of the pty.
51New code should not try to allocate pseudo-terminals using this
52interface.
53It is only provided for compatibility with older C libraries
54that tried to open such devices when
55.Xr posix_openpt 2
56was being called.
211.Sh FILES
57.Sh FILES
212The files used by the
213.Bx
214pseudo terminals implementation are:
58The BSD-style compatibility pseudo-terminal driver uses the following
59device names:
215.Pp
60.Pp
216.Bl -tag -width ".Pa /dev/tty[p-sP-S][0-9a-v]" -compact
217.It Pa /dev/pty[p-sP-S][0-9a-v]
218master pseudo terminals
219.It Pa /dev/tty[p-sP-S][0-9a-v]
220slave pseudo terminals
61.Bl -tag -width ".Pa /dev/pty[l-sL-S][0-9a-v]"
62.It Pa /dev/pty[l-sL-S][0-9a-v]
63Pseudo-terminal master devices.
64.It Pa /dev/tty[l-sL-S][0-9a-v]
65Pseudo-terminal slave devices.
221.El
66.El
222.Pp
223The files used by the pts implementation are:
224.Pp
225.Bl -tag -width ".Pa /dev/pts/[num]" -compact
226.It Pa /dev/ptmx
227control device, returns a file descriptor to a new master pseudo terminal
228when opened.
229.It Pa /dev/pty[num]
230master pseudo terminals
231.It Pa /dev/pts/[num]
232slave pseudo terminals
233.El
234.Sh DIAGNOSTICS
235None.
236.Sh SEE ALSO
67.Sh DIAGNOSTICS
68None.
69.Sh SEE ALSO
70.Xr posix_openpt 2 ,
71.Xr pts 4 ,
237.Xr tty 4
238.Sh HISTORY
72.Xr tty 4
73.Sh HISTORY
74A
75pseudo-terminal driver appeared in
76.Bx 4.2 .
77.Sh BUGS
78Unlike previous implementations, the master slave device nodes are
79destroyed when the PTY becomes unused.
80A call to
81.Xr stat 2
82on a nonexistent master device will already cause a new master device
83node to be created.
84The master device can only be destroyed by opening and closing it.
85.Pp
239The
240.Nm
86The
87.Nm
241driver appeared in
242.Bx 4.2 .
88driver cannot be unloaded, because it cannot determine if it is being
89used.