1pty(7D)                             Devices                            pty(7D)
2
3
4

NAME

6       pty - pseudo-terminal driver
7

DESCRIPTION

9       The  pty  driver  provides  support  for a pair of devices collectively
10       known as a pseudo-terminal. The two devices comprising a  pseudo-termi‐
11       nal  are  known  as  a controller and a slave. The slave device distin‐
12       guishes between the B0 baud rate and other baud rates specified in  the
13       c_cflag  word  of  the  termios  structure, and the CLOCAL flag in that
14       word. It does not support any of the other  termio(7I)  device  control
15       functions  specified by flags in the c_cflag word of the termios struc‐
16       ture and by the IGNBRK,   IGNPAR,   PARMRK,   or  INPCK  flags  in  the
17       c_iflag word of the termios structure, as these functions apply only to
18       asynchronous serial ports.  All other termio(7I) functions must be per‐
19       formed  by  STREAMS modules pushed atop the driver; when a slave device
20       is opened, the ldterm(7M) and ttcompat(7M) STREAMS modules are automat‐
21       ically  pushed  on top of the stream, providing the standard termio(7I)
22       interface.
23
24
25       Instead of having a hardware interface  and  associated  hardware  that
26       supports  the  terminal  functions,  the  functions  are implemented by
27       another process manipulating the controller device of the pseudo-termi‐
28       nal.
29
30
31       The controller and the slave devices of the pseudo-terminal are tightly
32       connected. Any data written on the controller device is  given  to  the
33       slave  device  as input, as though it had been received from a hardware
34       interface. Any data written on the slave terminal can be read from  the
35       controller device (rather than being transmitted from a UAR).
36
37
38       By default, 48 pseudo-terminal pairs are configured as follows:
39
40         /dev/pty[p-r][0-9a-f] controller devices
41         /dev/tty[p-r][0-9a-f] slave devices
42
43

IOCTLS

45       The  standard  set  of termio ioctls are supported by the slave device.
46       None of the bits in the c_cflag word have any effect on the pseudo-ter‐
47       minal, except that if the baud rate is set to B0, it will appear to the
48       process on the controller device as if the last process  on  the  slave
49       device  had  closed the line; thus, setting the baud rate to B0 has the
50       effect of ``hanging up'' the pseudo-terminal, just as it has the effect
51       of ``hanging up'' a real terminal.
52
53
54       There  is  no notion of ``parity'' on a pseudo-terminal, so none of the
55       flags in the c_iflag word that control the processing of parity  errors
56       have  any effect. Similarly, there is no notion of a ``break'', so none
57       of the flags that control the processing of breaks,  and  none  of  the
58       ioctls that generate breaks, have any effect.
59
60
61       Input  flow control is automatically performed; a process that attempts
62       to write to the controller device will be blocked if  too  much  uncon‐
63       sumed  data  is  buffered  on the slave device.  The input flow control
64       provided by the IXOFF flag in the c_iflag word is not supported.
65
66
67       The delays specified in the c_oflag word are not supported.
68
69
70       As there are no modems involved in a pseudo-terminal, the  ioctls  that
71       return or alter the state of modem control lines are silently ignored.
72
73
74       A  few special ioctls are provided on the controller devices of pseudo-
75       terminals to provide the functionality needed by applications  programs
76       to emulate real hardware interfaces:
77
78       TIOCSTOP      The argument is ignored. Output to the pseudo-terminal is
79                     suspended, as if a STOP character had been typed.
80
81
82       TIOCSTART     The argument is ignored. Output to the pseudo-terminal is
83                     restarted, as if a START character had been typed.
84
85
86       TIOCPKT       The  argument is a pointer to an int. If the value of the
87                     int is non-zero, packet mode is enabled; if the value  of
88                     the  int is zero, packet mode is disabled. When a pseudo-
89                     terminal is in packet mode, each subsequent read(2)  from
90                     the  controller  device  will  return data written on the
91                     slave  device  preceded  by  a  zero  byte  (symbolically
92                     defined  as  TIOCPKT_DATA),   or a single byte reflecting
93                     control status information.  In the latter case, the byte
94                     is an inclusive-or of zero or more of the bits:
95
96                     TIOCPKT_FLUSHREAD     whenever  the  read  queue  for the
97                                           terminal is flushed.
98
99
100                     TIOCPKT_FLUSHWRITE    whenever the write  queue  for  the
101                                           terminal is flushed.
102
103
104                     TIOCPKT_STOP          whenever  output to the terminal is
105                                           stopped using ^S.
106
107
108                     TIOCPKT_START         whenever output to the terminal  is
109                                           restarted.
110
111
112                     TIOCPKT_DOSTOP        whenever  XON/XOFF  flow control is
113                                           enabled after being disabled; it is
114                                           considered   ``enabled''  when  the
115                                           IXON flag in the  c_iflag  word  is
116                                           set,  the  VSTOP member of the c_cc
117                                           array is ^S and the  VSTART  member
118                                           of the c_cc array is ^Q.
119
120
121                     TIOCPKT_NOSTOP        whenever  XON/XOFF  flow control is
122                                           disabled after being enabled.
123
124
125
126       TIOCREMOTE    The argument is a pointer to an int. If the value of  the
127                     int  is non-zero, remote mode is enabled; if the value of
128                     the int is zero, remote mode is disabled. This  mode  can
129                     be enabled or disabled independently of packet mode. When
130                     a pseudo-terminal is in remote mode, input to  the  slave
131                     device  of the pseudo-terminal is flow controlled and not
132                     input edited (regardless of the mode the  slave  side  of
133                     the pseudo-terminal). Each write to the controller device
134                     produces a record boundary for the  process  reading  the
135                     slave  device.   In normal usage, a write of data is like
136                     the data typed as a line on the terminal; a  write  of  0
137                     bytes  is  like typing an EOF character. Note: this means
138                     that a process writing to a pseudo-terminal controller in
139                     remote mode must keep track of line boundaries, and write
140                     only one line at a time to the controller.  If, for exam‐
141                     ple,  it were to buffer up several NEWLINE characters and
142                     write them to the controller with one write(),  it  would
143                     appear to a process reading from the slave as if a single
144                     line containing several NEWLINE characters had been typed
145                     (as if, for example, a user had typed the LNEXT character
146                     before typing all but the last of those  NEWLINE  charac‐
147                     ters).  Remote  mode  can  be used when doing remote line
148                     editing in a window manager, or whenever flow  controlled
149                     input is required.
150
151

EXAMPLES

153         #include <fcntl.h>
154         #include <sys/termios.h>
155
156         int fdm fds;
157         fdm = open("/dev/ptyp0, O_RDWR);  /* open master */
158         fds = open("/dev/ttyp0, O_RDWR);  /* open slave */
159
160

FILES

162       /dev/pty[p-z][0-9a-f]    pseudo-terminal controller devices
163
164
165       /dev/tty[p-z][0-9a-f]    pseudo-terminal slave devices
166
167

SEE ALSO

169       rlogin(1), rlogind(1M), ldterm(7M), termio(7I), ttcompat(7M),
170

NOTES

172       It  is  apparently not possible to send an EOT by writing zero bytes in
173       TIOCREMOTE mode.
174
175
176
177SunOS 5.11                        8 Aug 1994                           pty(7D)
Impressum