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

NAME

6       pts - STREAMS pseudo-tty slave 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 nodes for the
13       slave  driver (N is determined at installation time) must be installed.
14       The names of the slave devices are /dev/pts/M where M has the values  0
15       through  N-1. When the master device is opened, the corresponding slave
16       device is automatically locked out. No user may open that slave  device
17       until  its  permissions are adjusted and the device unlocked by calling
18       functions grantpt(3C) and unlockpt(3C). The user can  then  invoke  the
19       open  system  call  with  the  name that is returned by the ptsname(3C)
20       function. See the example below.
21
22
23       Only one open is allowed on a master device. Multiple opens are allowed
24       on  the slave device. After both the master and slave have been opened,
25       the user has two file descriptors which are end points of a full duplex
26       connection  composed of two streams automatically connected at the mas‐
27       ter and slave drivers. The user may then push modules onto either  side
28       of  the stream pair. The user needs to push the ptem(7M) and ldterm(7M)
29       modules onto the slave side of the  pseudo-terminal  subsystem  to  get
30       terminal semantics.
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. Since 0-length messages are used  to  indicate  that  the
49       process on the slave side has closed and should be interpreted that way
50       by the process on the master  side,  applications  on  the  slave  side
51       should  not  write 0-length messages. If that occurs, the write returns
52       0, and the 0-length message is discarded by the  ptem module.
53
54
55       The standard STREAMS system calls can access  the  pseudo-tty  devices.
56       The slave devices support the O_NDELAY and O_NONBLOCK flags.
57

EXAMPLES

59         int    fdm fds;
60         char   *slavename;
61         extern char *ptsname();
62
63         fdm = open("/dev/ptmx", O_RDWR);  /* open master */
64         grantpt(fdm);                     /* change permission of   slave */
65         unlockpt(fdm);                    /* unlock slave */
66         slavename = ptsname(fdm);         /* get name of slave */
67         fds = open(slavename, O_RDWR);    /* open slave */
68         ioctl(fds, I_PUSH, "ptem");       /* push ptem */
69         ioctl(fds, I_PUSH, "ldterm");     /* push ldterm*/
70
71

FILES

73       /dev/ptmx     master clone device
74
75
76       /dev/pts/M    slave devices (M = 0 -> N-1)
77
78

SEE ALSO

80       grantpt(3C), ptsname(3C), unlockpt(3C), ldterm(7M), ptm(7D), ptem(7M)
81
82
83       STREAMS Programming Guide
84
85
86
87SunOS 5.11                        21 Aug 1992                          pts(7D)
Impressum