Merge commit 'ad3ad82ad2fb99c424a8482bd1908d08b990ccea'
[unleashed.git] / share / man / man7d / ptm.7d
blob83c783029398e8bed1a54e3b9b6481e35a8b53b9
1 '\" te
2 .\"  Copyright (c) 1997, Sun Microsystems, Inc.
3 .\"  All Rights Reserved
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH PTM 7D "Feb 5, 1997"
8 .SH NAME
9 ptm \- STREAMS pseudo-tty master driver
10 .SH DESCRIPTION
11 .sp
12 .LP
13 The pseudo-tty subsystem simulates a terminal connection, where the master side
14 represents the terminal and the slave represents the user process's special
15 device end point. In order to use the pseudo-tty subsystem, a node for the
16 master side driver \fB/dev/ptmx\fR and \fBN\fR number of nodes for the slave
17 driver must be installed. See \fBpts\fR(7D). The master device is set up as a
18 cloned device where its major device number is the major for the clone device
19 and its minor device number is the major for the \fBptm\fR driver. There are no
20 nodes in the file system for master devices. The master pseudo driver is opened
21 using the \fBopen\fR(2) system call with \fB/dev/ptmx\fR as the device
22 parameter. The clone open finds the next available minor device for the
23 \fBptm\fR major device.
24 .sp
25 .LP
26 A master device is available only if it and its corresponding slave device are
27 not already open. When the master device is opened, the corresponding slave
28 device is automatically locked out. Only one open is allowed on a master
29 device.  Multiple opens are allowed on the slave device. After both the master
30 and slave have been opened, the user has two file descriptors which are the end
31 points of a full duplex connection composed of two streams which are
32 automatically connected at the master and slave drivers. The user may then push
33 modules onto either side of the stream pair.
34 .sp
35 .LP
36 The master and slave drivers pass all messages to their adjacent queues. Only
37 the \fBM_FLUSH\fR needs some processing. Because the read queue of one side is
38 connected to the write queue of the other, the \fBFLUSHR\fR flag is changed to
39 the \fBFLUSHW\fR flag and vice versa. When the master device is closed an
40 \fBM_HANGUP\fR message is sent to the slave device which will render the device
41 unusable. The process on the slave side gets the errno \fBEIO\fR when
42 attempting to write on that stream but it will be able to read any data
43 remaining on the stream head read queue. When all the data has been read,
44 \fBread()\fR returns 0 indicating that the stream can no longer be used. On the
45 last close of the slave device, a 0-length message is sent to the master
46 device. When the application on the master side issues a \fBread()\fR or
47 \fBgetmsg()\fR and 0 is returned, the user of the master device decides whether
48 to issue a \fBclose()\fR that dismantles the pseudo-terminal subsystem. If the
49 master device is not closed, the pseudo-tty subsystem will be available to
50 another user to open the slave device.
51 .sp
52 .LP
53 If \fBO_NONBLOCK\fR or \fBO_NDELAY\fR is set, read on the master side returns
54 \(mi1 with errno set to \fBEAGAIN\fR if no data is available, and write returns
55 \(mi1 with errno set to \fBEAGAIN\fR if there is internal flow control.
56 .SH IOCTLS
57 .sp
58 .LP
59 The master driver supports the \fBISPTM\fR and \fBUNLKPT\fR ioctls that are
60 used by the functions \fBgrantpt\fR(3C), \fBunlockpt\fR(3C) and
61 \fBptsname\fR(3C). The ioctl \fBISPTM\fR determines whether the file descriptor
62 is that of an open master device. On success, it returns the 0. The ioctl
63 \fBUNLKPT\fR unlocks the master and slave devices. It returns 0 on success. On
64 failure, the errno is set to \fBEINVAL\fR indicating that the master device is
65 not open.
66 .SH FILES
67 .sp
68 .ne 2
69 .na
70 \fB\fB/dev/ptmx\fR\fR
71 .ad
72 .RS 14n
73 master clone device
74 .RE
76 .sp
77 .ne 2
78 .na
79 \fB\fB/dev/pts/M\fR\fR
80 .ad
81 .RS 14n
82 slave devices (M = 0 -> N-1)
83 .RE
85 .SH SEE ALSO
86 .sp
87 .LP
88 \fBgrantpt\fR(3C), \fBptsname\fR(3C), \fBunlockpt\fR(3C), \fBpckt\fR(7M),
89 \fBpts\fR(7D)
90 .sp
91 .LP
92 \fISTREAMS Programming Guide\fR