DIRECTORY PseudoTerminal USING [PseudoTerminal], Rope USING [ROPE], UnixTypes USING [FileDescriptor]; Plumber: CEDAR DEFINITIONS ~ { Wire: TYPE ~ REF WireRep ¬ NIL; -- Wire is here only for Conduit WireRep: TYPE ~ RECORD [ active: BOOLEAN ¬ FALSE, connectedTo: Rope.ROPE ¬ NIL, process: PROCESS ¬ NIL, result: REF ¬ NIL ]; Conduit: PUBLIC TYPE = REF ConduitRep; ConduitRep: PUBLIC TYPE = MONITORED RECORD [ closing: BOOLEAN ¬ FALSE, pty: PseudoTerminal.PseudoTerminal ¬ NIL, stdin: Wire, stdout: Wire, stderr: Wire, message: REF ]; SpawnResult: TYPE = RECORD [res: INT, errno: INT, details: REF]; Error: ERROR [code: ATOM, msg: Rope.ROPE]; Spawn: PROC [ command: Rope.ROPE, wd: Rope.ROPE, stdin: REF, stdout: REF, stderr: REF, exec: BOOL, tty: BOOL, debug: BOOL ¬ FALSE, noisy: BOOL ¬ FALSE, reportSourceFD: PROC[fd: UnixTypes.FileDescriptor] ¬ NIL ] RETURNS [SpawnResult]; SpawnWithConduit: PROC [ conduit: Conduit, command: Rope.ROPE, wd: Rope.ROPE, exec: BOOLEAN, tty: BOOLEAN, reportSourceFD: PROC[fd: UnixTypes.FileDescriptor] ¬ NIL ] RETURNS [SpawnResult]; MakeConduit: PROC [stdin, stdout, stderr: REF, debug:BOOL¬FALSE, noisy:BOOL¬ FALSE] RETURNS [Conduit]; Terminate: PROC [conduit: Conduit, reason: ATOM]; }. ͺ Plumber.mesa Copyright Σ 1989, 1992 by Xerox Corporation. All rights reserved. Michael Plass, September 25, 1989 3:36:30 pm PDT Peter B. Kessler, January 15, 1990 5:36:06 pm PST Norman Adams, May 18, 1990 10:43 am PDT Welch, March 7, 1991 4:42 pm PST - extracted PseudoTerminal Willie-s, June 12, 1992 2:41 pm PDT -- Conduit should be opaque, but that makes reloading impossible, or requires that we add a private interface soley for the purpose of hiding Conduit. Fooey. The command is the command to hand to a /bin/sh. The wd is the working directory to cd to before spawning the shell. The input REF's may be file names (Rope.ROPE, REF TEXT), or IO.STREAM's. The returned SpawnResult.details is a LIST of the result of the spawn, errno, and the results of the stream copiers. If exec then exec the command in the shell. If tty then add -t /dev/tty?? and -p /dev/pty?? options to command. The procedure reportSourceFD is called on the source Unix file descriptor. Spawn[...stdin, stdout, stderr...] is equivalent to SpawnWithConduit[...MakeConduit[stdin, stdout, stderr]...]. The only advantage to the latter is that if you hang on to the conduit, you can call Terminate on it. ΚΞ•NewlineDelimiter –(cedarcode) style™codešœ ™ Kšœ Πerœ7™BK™0K™1K™'K™;K™#K™—šΟk œ˜ Kšœžœ˜&Kšœžœžœ˜Kšœ žœ˜!K˜—KšΟnœžœž œ˜˜šœžœžœ žœΟc"˜Cšœ žœžœ˜Kšœžœžœ˜Kšœžœžœ˜Kšœ žœžœ˜Kšœžœž˜K˜K˜——Kšœž™žKšœ ž œžœ ˜'šœ ž œžœ˜,Kšœ žœžœ˜Kšœ%žœ˜)K˜ Kšœ ˜ Kšœ ˜ Kšœ ž˜ Kšœž˜—Kš œ žœžœžœ žœ žœ˜@K˜šŸœžœžœ žœ˜*K˜—š Ÿœžœžœ žœ žœ žœ žœžœžœ žœžœ žœžœžœ!žœžœ˜μK™0K™CKš œ žœžœžœžœžœžœ™HKšœžœ žœJ™tKšœ+™+KšœC™CKšœJ™JK™—KšœΧ™ΧK™KšŸœžœ$žœ žœ žœžœžœ!žœžœ˜ΐK˜šŸ œžœžœžœžœžœžœ˜TKšžœ ˜—K˜KšŸ œžœžœ˜1K˜Kšœ˜——…—Ϊ R