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.man.txt
          +++ new/usr/src/man/man7d/pts.7d.man.txt
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18         device unlocked by calling functions grantpt(3C) and unlockpt(3C). The
  19   19         user can then invoke the open system call with the name that is
  20   20         returned by the ptsname(3C) function. See the example below.
  21   21  
  22   22  
  23   23         Only one open is allowed on a master device. Multiple opens are allowed
  24   24         on the slave device. After both the master and slave have been opened,
  25   25         the user has two file descriptors which are end points of a full duplex
  26   26         connection composed of two streams automatically connected at the
  27   27         master and slave drivers. The user may then push modules onto either
  28      -       side of the stream pair. The user needs to push the ptem(7M) and
  29      -       ldterm(7M) modules onto the slave side of the pseudo-terminal subsystem
  30      -       to get terminal semantics.
       28 +       side of the stream pair. Unless compiled in strict XPG4v2 mode (see
       29 +       below), the consumer needs to push the ptem(7M) and ldterm(7M) modules
       30 +       onto the slave side of the pseudo-terminal subsystem to get terminal
       31 +       semantics.
  31   32  
  32   33  
  33   34         The master and slave drivers pass all messages to their adjacent
  34   35         queues. Only the M_FLUSH needs some processing. Because the read queue
  35   36         of one side is connected to the write queue of the other, the FLUSHR
  36   37         flag is changed to the FLUSHW flag and vice versa. When the master
  37   38         device is closed an M_HANGUP message is sent to the slave device which
  38   39         will render the device unusable. The process on the slave side gets the
  39   40         errno EIO when attempting to write on that stream but it will be able
  40   41         to read any data remaining on the stream head read queue. When all the
  41   42         data has been read, read returns 0 indicating that the stream can no
  42   43         longer be used. On the last close of the slave device, a 0-length
  43   44         message is sent to the master device. When the application on the
  44   45         master side issues a read() or getmsg() and 0 is returned, the user of
  45   46         the master device decides whether to issue a close() that dismantles
  46   47         the pseudo-terminal subsystem. If the master device is not closed, the
  47   48         pseudo-tty subsystem will be available to another user to open the
  48   49         slave device. Since 0-length messages are used to indicate that the
  49   50         process on the slave side has closed and should be interpreted that way
  50   51         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.
       52 +       should not write 0-length messages. Unless the application is compiled
       53 +       in strict XPG4v2 mode (see below) then any 0-length messages written on
       54 +       the slave side will be discarded by the ptem module.
  53   55  
  54   56  
  55   57         The standard STREAMS system calls can access the pseudo-tty devices.
  56   58         The slave devices support the O_NDELAY and O_NONBLOCK flags.
  57   59  
       60 +STRICT XPG4v2 MODE
       61 +       XPG4v2 requires that open of a slave pseudo terminal device provides
       62 +       the process with an interface that is identical to the terminal
       63 +       interface (without having to explicitly push any modules to achieve
       64 +       this). It also requires that 0-length messages written on the slave
       65 +       side will be propagated to the master.
       66 +
       67 +       Experience has shown, however, that most software does not expect slave
       68 +       pty devices to operate in this manner and therefore this
       69 +       XPG4v2-compliant behaviour is disabled in illumos by default.
       70 +
       71 +       To enable it for an application, the _XPG4_2 and _STRICT_SYMBOLS macros
       72 +       must be set during compilation and the application must be linked with
       73 +       values-xpg4.o or values-xp6.o.
       74 +
  58   75  EXAMPLES
  59   76           int    fdm fds;
  60   77           char   *slavename;
  61   78           extern char *ptsname();
  62   79  
  63   80           fdm = open("/dev/ptmx", O_RDWR);  /* open master */
  64   81           grantpt(fdm);                     /* change permission of   slave */
  65   82           unlockpt(fdm);                    /* unlock slave */
  66   83           slavename = ptsname(fdm);         /* get name of slave */
  67   84           fds = open(slavename, O_RDWR);    /* open slave */
↓ open down ↓ 4 lines elided ↑ open up ↑
  72   89  FILES
  73   90         /dev/ptmx
  74   91                       master clone device
  75   92  
  76   93  
  77   94         /dev/pts/M
  78   95                       slave devices (M = 0 -> N-1)
  79   96  
  80   97  
  81   98  SEE ALSO
  82      -       grantpt(3C), ptsname(3C), unlockpt(3C), ldterm(7M), ptm(7D), ptem(7M)
       99 +       grantpt(3C), ptsname(3C), unlockpt(3C), ldterm(7M), ptm(7D), ptem(7M),
      100 +       standards(5)
  83  101  
  84  102  
  85  103         STREAMS Programming Guide
  86  104  
  87  105  
  88  106  
  89      -                                August 21, 1992                        PTS(7D)
      107 +                               February 29, 2020                       PTS(7D)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX