Print this page
12306 XPG4v2 slave pty behaviour should generally be disabled
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Change-ID: I7ccd399c22866f34dd20c6bb9d28e77ba4e24c67

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man7d/pts.7d
          +++ new/usr/src/man/man7d/pts.7d
   1    1  '\" te
        2 +.\" Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
   2    3  .\"  Copyright 1992 Sun Microsystems
   3    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.
   4    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.
   5    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]
   6      -.TH PTS 7D "Aug 21, 1992"
        7 +.TH PTS 7D "Feb 29, 2020"
   7    8  .SH NAME
   8    9  pts \- STREAMS pseudo-tty slave driver
   9   10  .SH DESCRIPTION
  10   11  .sp
  11   12  .LP
  12   13  The pseudo-tty subsystem simulates a terminal connection, where the master side
  13   14  represents the terminal and the slave represents the user process's special
  14   15  device end point. In order to use the pseudo-tty subsystem, a node for the
  15   16  master side driver \fB/dev/ptmx\fR and N nodes for the slave driver (N is
  16   17  determined at installation time) must be installed. The names of the slave
↓ open down ↓ 2 lines elided ↑ open up ↑
  19   20  locked out. No user may open that slave device until its permissions are
  20   21  adjusted and the device unlocked by calling functions \fBgrantpt\fR(3C) and
  21   22  \fBunlockpt\fR(3C). The user can then invoke the open system call with the name
  22   23  that is returned by the \fBptsname\fR(3C) function. See the example below.
  23   24  .sp
  24   25  .LP
  25   26  Only one open is allowed on a master device. Multiple opens are allowed on the
  26   27  slave device. After both the master and slave have been opened, the user has
  27   28  two file descriptors which are end points of a full duplex connection composed
  28   29  of two streams automatically connected at the master and slave drivers. The
  29      -user may then push modules onto either side of the stream pair. The user needs
  30      -to push the \fBptem\fR(7M) and \fBldterm\fR(7M) modules onto the slave side of
  31      -the pseudo-terminal subsystem to get terminal semantics.
       30 +user may then push modules onto either side of the stream pair. Unless
       31 +compiled in strict XPG4v2 mode (see below), the consumer needs to push the
       32 +\fBptem\fR(7M) and \fBldterm\fR(7M) modules onto the slave side of the
       33 +pseudo-terminal subsystem to get terminal semantics.
  32   34  .sp
  33   35  .LP
  34   36  The master and slave drivers pass all messages to their adjacent queues. Only
  35   37  the \fBM_FLUSH\fR needs some processing. Because the read queue of one side is
  36   38  connected to the write queue of the other, the \fBFLUSHR\fR flag is changed to
  37   39  the \fBFLUSHW\fR flag and vice versa. When the master device is closed an
  38   40  \fBM_HANGUP\fR message is sent to the slave device which will render the device
  39   41  unusable. The process on the slave side gets the errno \fBEIO\fR when
  40   42  attempting to write on that stream but it will be able to read any data
  41   43  remaining on the stream head read queue. When all the data has been read, read
  42   44  returns 0 indicating that the stream can no longer be used. On the last close
  43   45  of the slave device, a 0-length message is sent to the master device. When the
  44   46  application on the master side issues a \fBread()\fR or \fBgetmsg()\fR and 0 is
  45   47  returned, the user of the master device decides whether to issue a
  46   48  \fBclose()\fR that dismantles the pseudo-terminal subsystem. If the master
  47   49  device is not closed, the pseudo-tty subsystem will be available to another
  48   50  user to open the slave device. Since 0-length messages are used to indicate
  49   51  that the process on the slave side has closed and should be interpreted that
  50   52  way by the process on the master side, applications on the slave side should
  51      -not write 0-length messages. If that occurs, the write returns 0, and the
  52      -0-length message is discarded by the  \fBptem\fR module.
       53 +not write 0-length messages. Unless the application is compiled in strict
       54 +XPG4v2 mode (see below) then any 0-length messages written on the slave side
       55 +will be discarded by the \fBptem\fR module.
  53   56  .sp
  54   57  .LP
  55   58  The standard STREAMS system calls can access the pseudo-tty devices. The slave
  56   59  devices support the \fBO_NDELAY\fR and \fBO_NONBLOCK\fR flags.
       60 +.SH STRICT XPG4v2 MODE
       61 +.sp
       62 +XPG4v2 requires that open of a slave pseudo terminal device provides the
       63 +process with an interface that is identical to the terminal interface (without
       64 +having to explicitly push any modules to achieve this). It also requires that
       65 +0-length messages written on the slave side will be propagated to the master.
       66 +.sp
       67 +Experience has shown, however, that most software does not expect slave pty
       68 +devices to operate in this manner and therefore this XPG4v2-compliant
       69 +behaviour is disabled in illumos by default.
       70 +.sp
       71 +To enable it for an application, the \fB_XPG4_2\fR and \fB_STRICT_SYMBOLS\fR
       72 +macros must be set during compilation and the application must be linked with
       73 +\fBvalues-xpg4.o\fR or \fBvalues-xp6.o\fR.
  57   74  .SH EXAMPLES
  58   75  .sp
  59   76  .in +2
  60   77  .nf
  61   78  int    fdm fds;
  62   79  char   *slavename;
  63   80  extern char *ptsname();
  64   81  
  65   82  fdm = open("/dev/ptmx", O_RDWR);  /* open master */
  66   83  grantpt(fdm);                     /* change permission of       slave */
↓ open down ↓ 21 lines elided ↑ open up ↑
  88  105  \fB\fB/dev/pts/M\fR\fR
  89  106  .ad
  90  107  .RS 14n
  91  108  slave devices (M = 0 -> N-1)
  92  109  .RE
  93  110  
  94  111  .SH SEE ALSO
  95  112  .sp
  96  113  .LP
  97  114  \fBgrantpt\fR(3C), \fBptsname\fR(3C), \fBunlockpt\fR(3C), \fBldterm\fR(7M),
  98      -\fBptm\fR(7D), \fBptem\fR(7M)
      115 +\fBptm\fR(7D), \fBptem\fR(7M), \fBstandards\fR(5)
  99  116  .sp
 100  117  .LP
 101  118  \fISTREAMS Programming Guide\fR
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX