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

@@ -23,12 +23,14 @@
  * Use is subject to license terms.
  */
 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
 /*        All Rights Reserved   */
 
+/*
+ * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
+ */
 
-
 /*
  * Pseudo Terminal Slave Driver.
  *
  * The pseudo-tty subsystem simulates a terminal connection, where the master
  * side represents the terminal and the slave represents the user process's

@@ -104,10 +106,11 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/sysmacros.h>
 #include <sys/stream.h>
 #include <sys/stropts.h>
+#include <sys/strsubr.h>
 #include <sys/stat.h>
 #include <sys/errno.h>
 #include <sys/debug.h>
 #include <sys/cmn_err.h>
 #include <sys/ptms.h>

@@ -335,21 +338,20 @@
         }
 
         DDBGP("ptsopen: p = %p\n", (uintptr_t)ptsp);
         DDBG("ptsopen: state = %x\n", ptsp->pt_state);
 
-
         ASSERT(ptsp->pt_minor == dminor);
 
         if ((ptsp->pt_state & PTLOCK) || !(ptsp->pt_state & PTMOPEN)) {
                 mutex_exit(&ptsp->pt_lock);
                 mutex_exit(&ptms_lock);
                 return (EAGAIN);
         }
 
         /*
-         * if already, open simply return...
+         * if already open, simply return...
          */
         if (ptsp->pt_state & PTSOPEN) {
                 ASSERT(rqp->q_ptr == ptsp);
                 ASSERT(ptsp->pts_rdq == rqp);
                 mutex_exit(&ptsp->pt_lock);

@@ -384,10 +386,13 @@
         WR(rqp)->q_ptr = rqp->q_ptr = ptsp;
 
         mutex_exit(&ptsp->pt_lock);
         mutex_exit(&ptms_lock);
 
+        if (ptsp->pt_state & PTSTTY)
+                STREAM(rqp)->sd_flag |= STRXPG4TTY;
+
         qprocson(rqp);
 
         /*
          * After qprocson pts driver is fully plumbed into the stream and can
          * send/receive messages. Setting pts_rdq will allow master side to send

@@ -414,12 +419,10 @@
         putnext(rqp, mop);
 
         return (0);
 }
 
-
-
 /*
  * Find the address to private data identifying the slave's write
  * queue. Send a 0-length msg up the slave's read queue to designate
  * the master is closing. Uattach the master from the slave by nulling
  * out master's write queue field in private data.