PseudoTerminalDoc.tioga
Brent Welch, September 26, 1990 9:32 am PDT
PseudoTerminal
PCEDAR 2.0 % FOR INTERNAL XEROX USE ONLY
PseudoTerminal
UNIX pty access
Brent Welch
Ó Copyright 1990 Xerox Corporation. All rights reserved.
Abstract: PseudoTerminal is a small package that opens and closes UNIX pseudo terminals. A pseudo terminal is a two ended I/O stream like a pipe, except that it gets processed by the kernel's terminal module so it behaves like an ordinary terminal device.
Created by: Brent Welch (Extracted from Plumber)
Maintained by: Brent Welch <Welch>
Keywords: /dev/pty, UNIX, Pseudo Terminal
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
1. Introduction
A pseudo terminal (pty) is a matched pair of UNIX I/O streams that are connected via the UNIX kernel's terminal processing module. Data written on one of the UNIX I/O streams is available for reading on the other I/O stream, plus terminal-like line processing is done on the data stream. See the UNIX termio man page in Section 4 of the UNIX manual for extensive details on UNIX terminal devices.
The PseudoTerminal package handles the details of opening a UNIX pty. There are a set of available names for pty devices, and Allocate searches through the names for an unused one. The master end of the pty (/dev/ptyXX) is opened by Allocate, and the name of corresponding slave end (/dev/ttyXX) is returned for opening by the client. Thus Allocate returns an open UNIX file descriptor plus the name of the corresponding UNIX terminal device.
Close closes the UNIX file descriptor returned by Allocate.
A PseudoTerminal type is defined as a REF to a record that contains the open UNIX file descriptor and the name of the slave device. This is returned by Allocate and taken as an argument by Close.