HP-UX Reference (11i v3 07/02) - 7 Device (Special) Files, 9 General Information, Index (vol 10)

p
pty(7) pty(7)
usage, writing data is like typing the data as a line on a terminal; writing zero bytes is
equivalent to typing an end-of-file character (that is, the EOF character as defined in ter-
mio(7)). The data read by the slave side is identical to the data written on the master side.
Data written on the slave side and read on the master side with
TIOCREMOTE enabled is
still subject to the normal termio (7) processing.
TIOCREMOTE can be used when doing
remote line editing in a window manager, or whenever flow-controlled input is required.
Issuing a
TIOCMONITOR ioctl() request flushes all data buffered in the pseudo termi-
nal.
The following ioctl() requests, defined in
<sys/ptyio.h>, apply only to the master side of
pty.In
particular, these
ioctl() requests are only recognized when
TIOCTTY is enabled. When TIOCTTY is
disabled, these
ioctl() requests set and return the external variable
errno to [EINVAL].
TIOCBREAK Cause a break operation to be done on the slave side of the
pty, as if a user had pressed
the break key on a real terminal. Takes no parameter.
TIOCSTOP Stop data flowing from the slave side of the
pty to the master side (equivalent to typing
^S). Takes no parameter.
TIOCSTART Restart output (stopped by TIOCSTOP or by typing ˆS). Takes no parameter.
Flow-Control Input and Output Processing
The following terms are used to describe the flow of data through pseudo terminals. INPUT refers to data
flowing from the master side of a pty to the slave side. OUTPUT refers to data flowing from the slave side
of a pty to the master side.
When packet mode (TIOCPKT) is disabled and INPUT is stopped (see IXOFF, input modes, in termio(7)),
the next
read() from the master side of a pty returns a STOP character. When INPUT is restarted, the
next read() from the master side returns a START character. If packet mode (
TIOCPKT) is enabled, the
STOP or START character is preceded by a data packet indicator (
TIOCPKTDATA ). select() should be
used by the master-side server before each
write() request to properly handle INPUT flow control (see
select(2)).
When INPUT flow control is enabled, write() and select() are handled as follows: Write-selects on
the master side of a pty return true only if INPUT has not been stopped. If INPUT becomes stopped
while data is being written into the master side of a pty, the write returns with the number of bytes writ-
ten before INPUT was stopped. Writes done after INPUT is stopped return immediately with zero bytes
written.
When packet mode (TIOCPKT) is disabled and OUTPUT is stopped (see IXON, input modes in termio(7)),
each subsequent
read() from the master side of a pty returns with no data read. When OUTPUT is res-
tarted, each subsequent read() from the master side returns data written on the slave side. If packet
mode (TIOCPKT) is enabled, the first read() after OUTPUT has been stopped returns a
TIOCPKTSTOP
packet. All subsequent reads from the master side while OUTPUT is stopped returns a TIOCPKTDATA
packet with no data. When OUTPUT is restarted, the next read() from the master side returns a
TIOCPKTSTART packet. All subsequent reads from the master side return data written on the slave side
preceded by a TIOCPKTDATA packet. select() should be used by the master-side server before each
read() to properly handle OUTPUT flow control. Otherwise, reads from the master side of a
pty will
not be prevented when OUTPUT is stopped.
Trapping ioctl(), open(), close() Requests
When trapping is enabled, the master side is notified when the application on its slave side makes an
ioctl(), open(),orclose() request. For trapped ioctl() and open() requests, the slave side
is blocked (that is, the request does not complete) until the server on its master side acknowledges the
trapped request. For trapped close() requests, the slave slave does not block for an acknowledgement.
select() should be used by the master side server to receive notification of trapped ioctl(),
open(), and close() requests. When one of these requests is trapped, the select() returns with an
"exceptional condition" indicated for the slave side’s file descriptor. Other mechanisms for receiving
notification of trapped requests are defined below, but these mechanisms should be used only if select()
is not available.
When trapping is disabled (default condition), unrecognized slave ioctl() requests return an error, with
the external variable errno set to [EINVAL]. The only ioctl() requests recognized by the slave side
are those defined by termio(7) and only when TIOCTTY is enabled. When TIOCTTY is disabled, no
ioctl() requests are recognized by the slave side. If trapping is enabled and the master side closes,
trapping is disabled. If the master closes during the middle of a handshake with the slave, the handshake
HP-UX 11i Version 3: February 2007 3 Hewlett-Packard Company 127