PseudoTerminal.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Brent Welch, September 26, 1990 10:30 am PDT
Michael Plass, September 24, 1991 2:29 pm PDT
A UNIX PseudoTerminal is a two-ended I/O stream with one end controlled by a master process while the other end is treated like a normal UNIX tty by a slave process. The PseudoTerminal implementation uses "ptys" in order to control the I/O streams of UNIX programs running in the terminal emulator. The PseudoTerminal abstraction is used, for example, by Plumber and CedarConsole.
PseudoTerminal: TYPE ~ REF PseudoTerminalRep;
PseudoTerminalRep:
TYPE ~
RECORD [
controllerName: Rope.ROPE ¬ NIL, -- name of controller device
controllerFD: UnixTypes.FileDescriptor ¬ UnixTypes.FileDescriptor.error,
slaveName: Rope.ROPE ¬ NIL -- name of slave device
];
Error: ERROR [code: ATOM, msg: Rope.ROPE];
Allocate takes care of choosing an unused name for the pty. It opens the master end of the pty and returns the corresponding name of the slave tty for opening by the client. Allocate raises Error if there are no pty's available.
Allocate: PROC [] RETURNS [PseudoTerminal];
Close: PROC [pty: PseudoTerminal];
The client of Allocate might also find CHARPtrFromRefText useful in conjuction with UnixSyscalls.Read. Hunt it down in PlumberImpl.mesa, which obtains a scratch RefText and then casts it into a UNIX char * for use with read().
}.