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. 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. 15.\" 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 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)pty.4 8.2 (Berkeley) 11/30/93 29.\" 30.Dd August 20, 2008 31.Dt PTS 4 32.Os 33.Sh NAME 34.Nm pts 35.Nd pseudo-terminal driver 36.Sh DESCRIPTION 37The 38.Nm 39driver provides support for a device-pair termed a 40.Em pseudo-terminal . 41A pseudo-terminal is a pair of character devices, a 42.Em master 43device and a 44.Em slave 45device. 46The slave device provides to a process an interface identical 47to that described in 48.Xr tty 4 . 49However, whereas all other devices which provide the 50interface described in 51.Xr tty 4 52have a hardware device of some sort behind them, the slave 53device has, instead, another process manipulating 54it through the master half of the pseudo-terminal. 55That is, anything written on the master device is 56given to the slave device as input and anything written 57on the slave device is presented as input on the master 58device. 59.Pp 60The following 61.Xr ioctl 2 62calls apply only to pseudo-terminals: 63.Bl -tag -width TIOCPTMASTER 64.It Dv TIOCPKT 65Enable/disable 66.Em packet 67mode. 68Packet mode is enabled by specifying (by reference) 69a nonzero parameter and disabled by specifying (by reference) 70a zero parameter. 71When applied to the master side of a pseudo-terminal, each subsequent 72.Xr read 2 73from the terminal will return data written on the slave part of 74the pseudo-terminal preceded by a zero byte (symbolically 75defined as 76.Dv TIOCPKT_DATA ) , 77or a single byte reflecting control 78status information. 79In the latter case, the byte is an inclusive-or 80of zero or more of the bits: 81.Bl -tag -width TIOCPKT_FLUSHWRITE 82.It Dv TIOCPKT_FLUSHREAD 83whenever the read queue for the terminal is flushed. 84.It Dv TIOCPKT_FLUSHWRITE 85whenever the write queue for the terminal is flushed. 86.It Dv TIOCPKT_STOP 87whenever output to the terminal is stopped a la 88.Ql ^S . 89.It Dv TIOCPKT_START 90whenever output to the terminal is restarted. 91.It Dv TIOCPKT_DOSTOP 92whenever 93.Dv VSTOP 94is 95.Ql ^S 96and 97.Dv VSTART 98is 99.Ql ^Q . 100.It Dv TIOCPKT_NOSTOP 101whenever the start and stop characters are not 102.Ql ^S/^Q . 103.El 104.Pp 105While this mode is in use, the presence of control status information 106to be read from the master side may be detected by a 107.Xr select 2 108for exceptional conditions. 109.Pp 110This mode is used by 111.Xr rlogin 1 112and 113.Xr rlogind 8 114to implement a remote-echoed, locally 115.Ql ^S/^Q 116flow-controlled 117remote login with proper back-flushing of output; it can be 118used by other similar programs. 119.It Dv TIOCGPTN 120Obtain device unit number, which can be used to generate the filename of 121the pseudo-terminal slave device. 122This 123.Xr ioctl 2 124should not be used directly. 125Instead, the 126.Xr ptsname 3 127function should be used. 128.It Dv TIOCPTMASTER 129Determine whether the file descriptor is pointing to a pseudo-terminal 130master device. 131This 132.Xr ioctl 2 133should not be used directly. 134It is used to implement routines like 135.Xr grantpt 3 . 136.El 137.Sh FILES 138The files used by this 139pseudo-terminals implementation are: 140.Bl -tag -width ".Pa /dev/pts/[num]" 141.It Pa /dev/pts/[num] 142Pseudo-terminal slave devices. 143.El 144.Sh DIAGNOSTICS 145None. 146.Sh SEE ALSO 147.Xr posix_openpt 2 , 148.Xr grantpt 3 , 149.Xr ptsname 3 , 150.Xr pty 4 , 151.Xr tty 4 152.Sh HISTORY 153A 154pseudo-terminal driver appeared in 155.Bx 4.2 . 156In 157.Fx 8.0 , 158it was replaced with the 159.Nm 160driver. 161