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

NAME

6       ptm - STREAMS pseudo-tty master driver
7

DESCRIPTION

9       The  pseudo-tty  subsystem  simulates  a terminal connection, where the
10       master side represents the terminal and the slave represents  the  user
11       process's special device end point. In order to use the pseudo-tty sub‐
12       system, a node for the master side driver /dev/ptmx  and  N  number  of
13       nodes  for  the slave driver must be installed. See pts(7D). The master
14       device is set up as a  cloned device where its major device  number  is
15       the major for the clone device and its minor device number is the major
16       for the ptm driver. There are no nodes in the file  system  for  master
17       devices.  The  master  pseudo driver is opened using the open(2) system
18       call with /dev/ptmx as the device parameter. The clone open  finds  the
19       next available minor device for the ptm major device.
20
21
22       A  master  device  is  available only if it and its corresponding slave
23       device are not already open. When the master device is opened, the cor‐
24       responding  slave  device is automatically locked out. Only one open is
25       allowed on a master device.  Multiple opens are allowed  on  the  slave
26       device.  After both the master and slave have been opened, the user has
27       two file descriptors which are the end points of a full duplex  connec‐
28       tion  composed  of two streams which are automatically connected at the
29       master and slave drivers. The user may then push  modules  onto  either
30       side of the stream pair.
31
32
33       The  master  and  slave  drivers  pass  all  messages to their adjacent
34       queues. Only the M_FLUSH needs some processing. Because the read  queue
35       of  one  side  is connected to the write queue of the other, the FLUSHR
36       flag is changed to the FLUSHW flag and  vice  versa.  When  the  master
37       device  is closed an M_HANGUP message is sent to the slave device which
38       will render the device unusable. The process on the slave side gets the
39       errno  EIO  when attempting to write on that stream but it will be able
40       to read any data remaining on the stream head read queue. When all  the
41       data  has been read, read() returns 0 indicating that the stream can no
42       longer be used. On the last close of the slave device, a 0-length  mes‐
43       sage  is  sent to the master device. When the application on the master
44       side issues a read() or getmsg() and 0 is returned,  the  user  of  the
45       master  device  decides  whether to issue a close() that dismantles the
46       pseudo-terminal subsystem. If the master  device  is  not  closed,  the
47       pseudo-tty  subsystem  will  be  available  to another user to open the
48       slave device.
49
50
51       If O_NONBLOCK or O_NDELAY is set, read on the master  side  returns  −1
52       with  errno set to EAGAIN if no data is available, and write returns −1
53       with errno set to EAGAIN if there is internal flow control.
54

IOCTLS

56       The master driver supports the ISPTM and UNLKPT ioctls that are used by
57       the  functions  grantpt(3C),  unlockpt(3C)  and  ptsname(3C). The ioctl
58       ISPTM determines whether the file descriptor is that of an open  master
59       device. On success, it returns the 0. The ioctl UNLKPT unlocks the mas‐
60       ter and slave devices. It returns 0 on success. On failure,  the  errno
61       is set to EINVAL indicating that the master device is not open.
62

FILES

64       /dev/ptmx     master clone device
65
66
67       /dev/pts/M    slave devices (M = 0 -> N-1)
68
69

SEE ALSO

71       grantpt(3C), ptsname(3C), unlockpt(3C), pckt(7M), pts(7D)
72
73
74       STREAMS Programming Guide
75
76
77
78SunOS 5.11                        5 Feb 1997                           ptm(7D)
Impressum