Pseudo-tty emulation module -- ptem
Because the pseudo-tty subsystem has no hardware driver downstream from the
ldterm module to process the terminal ioctl calls, another module that
understands the ioctl commands is placed downstream from the ldterm.
This module, known as ptem, processes all the terminal ioctl commands
and mediates the passage of control information downstream.
ldterm and ptem together behave like a real terminal.
Because there is no real terminal or modem in the pseudo-tty subsystem, some of the
ioctl commands are ignored and cause only an acknowledgement of the command.
The ptem module keeps track of the terminal parameters set by the various
``set'' commands such as TCSETA or TCSETAW but does not usually perform any action.
For example, if one of the ``set'' ioctls is called, none of the bits in the
c_cflag field of termio has any effect on the pseudo-terminal
except if the baud rate is set to 0.
When setting the baud rate to 0, it has the effect of hanging up the pseudo-terminal.
The pseudo-terminal has no concept of parity so none of the flags in the
c_iflag that control the processing of parity errors have any effect.
The delays specified in the c_oflag field are not also supported.
The ptem module does the following:
-
Processes, if appropriate, and acknowledges receipt of the following ioctls
on its write queue by sending an M_IOCACK message back upstream:
TCSETA, TCSETAW, TCSETAF,
TCSETS, TCSETSW, TCSETSF,
TCGETA, TCGETS, and TCSBRK.
-
Keeps track of the window size; information needed for the
TIOCSWINSZ, TIOCGWINSZ, and JWINSIZE ioctl commands.
-
When it receives any other ioctl on its write queue, it sends an
M_IOCNAK message upstream.
-
It passes downstream the following ioctls after processing them:
TCSETA, TCSETAW, TCSETAF,
TCSETS, TCSETSW, TCSETSF, TCSBRK, and TIOCSWINSZ.
-
ptem frees any M_IOCNAK messages it receives on its read queue in case the
pckt module is not on the pseudo-terminal
subsystem and the above ioctls get to the master's Stream
head, which then sends an M_IOCNAK message.
-
In its open routine, the ptem module sends an M_SETOPTS
message upstream requesting allocation of a controlling tty.
-
When the ptem module receives an M_IOCTL message of type TCSBRK on its read
queue, it sends an M_IOCACK message downstream and an M_BREAK message upstream.
-
When it receives an ioctl message on its write queue to set the baud rate to
0 (TCSETAW with CBAUD set to B0), it sends an M_IOCACK message upstream and
a 0-length message downstream.
-
When it receives an M_IOCTL of type TIOCSIGNAL on its read queue, it sends an
M_IOCACK downstream and an M_PCSIG upstream where the signal number is the same as
in the M_IOCTL message.
-
When the ptem module receives an M_IOCTL of type TIOCREMOTE on its read queue,
it sends an M_IOCACK message downstream and the appropriate M_CTL message
upstream to enable/disable canonical processing.
-
When it receives an M_DELAY message on its read or write queue, it
discards the message and does not act on it.
-
When it receives an M_IOCTL message with type JWINSIZE on its write queue and if
the values in the jwinsize structure of ptem are not zero,
it sends an M_IOCACK message upstream with the jwinsize structure.
If the values are zero, it sends an M_IOCNAK message upstream.
-
When it receives an M_IOCTL message of type TIOCGWINSZ on its write queue and if
the values in the winsize structure are not zero, it sends an M_IOCACK
message upstream with the winsize structure.
If the values are zero, it sends an M_IOCNAK message upstream.
It also saves the information passed to it in the winsize structure
and sends a STREAMS signal message for signal
SIGWINCH upstream to the slave process if the size changed.
-
When the ptem module receives an M_IOCTL message with type TIOCGWINSZ on its
read queue and if the values in the winsize structure are not zero, it
sends an M_IOCACK message downstream with the winsize structure.
If the values are zero, it sends an M_IOCNAK message downstream.
It also saves the information passed to it in the winsize structure
and sends a STREAMS signal message for signal
SIGWINCH upstream to the slave process if the size changed.
-
All other messages not mentioned above are passed to the next
module or driver.
Next topic:
Remote mode
Previous topic:
Pseudo-tty subsystem architecture
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004