1 '\" te
   2 .\"  Copyright 1989 AT&T
   3 .\" Copyright (C) 1999, Sun Microsystems, Inc. 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 .\" Copyright 2022 Oxide Computer Company
   8 .Dd February 5, 2022
   9 .Dt PTEM 7M
  10 .Os
  11 .Sh NAME
  12 .Nm ptem
  13 .Nd STREAMS Pseudo-Terminal Emulation module
  14 .Sh SYNOPSIS
  15 .In unistd.h
  16 .In stropts.h
  17 .Ft int
  18 .Fo ioctl
  19 .Fa "int fildes" ,
  20 .Dv I_PUSH ,
  21 .Qq ptem
  22 .Fc
  23 .Sh DESCRIPTION
  24 .Nm ptem
  25 is a STREAMS module that emulates a terminal device when used in conjunction
  26 with the line discipline,
  27 .Xr ldterm 7M ,
  28 and the pseudo terminal driver,
  29 .Xr ptm 7D .
  30 .Pp
  31 The
  32 .Nm ptem
  33 module must be pushed
  34 .Po
  35 see
  36 .Dv I_PUSH
  37 in
  38 .Xr streamio 7I
  39 .Pc
  40 onto the subsidiary device of a pseudo-terminal STREAM, before the
  41 .Xr ldterm 7M
  42 module is pushed.
  43 .Ss Write-side Behaviour
  44 The
  45 .Dv TCSETA ,
  46 .Dv TCSETAF ,
  47 .Dv TCSETAW ,
  48 .Dv TCGETA ,
  49 .Dv TCSETS ,
  50 .Dv TCSETSW ,
  51 .Dv TCSETSF ,
  52 .Dv TCGETS ,
  53 .Dv TCSBRK ,
  54 .Dv JWINSIZE ,
  55 .Dv TIOCGWINSZ ,
  56 and
  57 .Dv TIOCSWINSZ
  58 .Xr termio 7I
  59 .Xr ioctl 2
  60 messages are processed and acknowledged.
  61 .Pp
  62 If
  63 .Em remote mode
  64 is not in effect,
  65 .Nm ptem
  66 handles the
  67 .Dv TIOCSTI
  68 ioctl by copying the argument bytes into an
  69 .Dv M_DATA
  70 message and passing it back up the read side.
  71 Regardless of the
  72 .Em remote mode
  73 setting,
  74 .Nm ptem
  75 acknowledges the ioctl and passes a copy of it downstream for possible further
  76 processing.
  77 .Pp
  78 A hang up
  79 .Po
  80 e.g.,
  81 .Ic stty 0
  82 .Pc
  83 is converted to a zero length
  84 .Dv M_DATA
  85 message and passed downstream.
  86 .Xr termio 7I
  87 .Sy cflags
  88 and window row and column information are stored locally, one per stream.
  89 .Dv M_DELAY
  90 messages are discarded.
  91 .Pp
  92 All other messages are passed downstream unmodified.
  93 .Ss Read-side Behaviour
  94 All messages are passed upstream unmodified with the following exceptions:
  95 .Bl -bullet
  96 .It
  97 All
  98 .Dv M_READ
  99 and
 100 .Dv M_DELAY
 101 messages are freed in both directions.
 102 .It
 103 A
 104 .Dv TCSBRK
 105 ioctl is converted to an
 106 .Dv M_BREAK
 107 message and passed upstream and an acknowledgement is returned downstream.
 108 .It
 109 A
 110 .Dv TIOCSIGNAL
 111 ioctl is converted into an
 112 .Dv M_PCSIG
 113 message, passed upstream, and an acknowledgement is returned downstream.
 114 .It
 115 A
 116 .Dv TIOCREMOTE
 117 ioctl is converted into an
 118 .Dv M_CTL
 119 message, acknowledged, and passed upstream; the resulting mode is retained for
 120 use in subsequent
 121 .Dv TIOCSTI
 122 parsing.
 123 .El
 124 .Sh SEE ALSO
 125 .Xr stty 1 ,
 126 .Xr ioctl 2 ,
 127 .Xr streamio 7I ,
 128 .Xr termio 7I ,
 129 .Xr ldterm 7M ,
 130 .Xr pckt 7M