DIRECTORY CedarProcess, IO, Rope, UnixTypes; UnixSpawnTCP: CEDAR DEFINITIONS ~ BEGIN FinishProc: TYPE ~ PROC [status: ATOM --$NotFound, $Completed--, clientData: REF ANY]; SpawnData: TYPE ~ RECORD [ fd1, fd2: UnixTypes.FileDescriptor, -- stdout or stderr fdOut: UnixTypes.FileDescriptor, -- stdout pid: INT, -- process id, for abort readOut: CedarProcess.ForkableProc, -- procedure forked for read stdout watch1, watch2: CedarProcess.Process, -- forked read process for fd1, fd2 readOutProcess: CedarProcess.Process, -- forked read process for stdout finish: FinishProc, -- called upon completion of Unix process clientData: REF ANY, -- passed to finish out, err: IO.STREAM]; -- out and err Cedar streams Spawn: PROC [ command: Rope.ROPE, out, err: IO.STREAM ¬ NIL, finish: FinishProc ¬ NIL, readOut: CedarProcess.ForkableProc ¬ NIL, clientData: REF ANY ¬ NIL] RETURNS [REF SpawnData]; Kill: PROC [s: REF SpawnData]; Write: PROC [s: REF SpawnData, rope: Rope.ROPE]; Close: PROC [s: REF SpawnData]; END. Μ UnixSpawnTCP.mesa Copyright Σ 1989, 1990, 1991 by Xerox Corporation. All rights reserved. Jules Bloomenthal August 23, 1992 1:13 pm PDT Spawn a Unix Process This uses tcp to transfer characters, whereas UnixSpawn uses the usually slower tty. command given to /bin/sh; NIL returned if error connecting to stdout or stderr. command's stderr sent to err; stdout sent to out if NIL readOut. If readOut non-NIL, it is expected to read s.fdOut; see implementation (ReadOut) for template. finish, if non-NIL, called upon command completion and passed clientData. Kill the spawned Unix process. Write to stdin associated with the Unix process the given rope. Close the Unix process's stdin with an end-of-stream. ΚA–(cedarcode) style•NewlineDelimiter ™šœ™Jšœ Πerœ=™HJ™-J™—šΟk œ#˜,J˜—JšΟn œžœž ˜Jšž˜headšΟl™™TJ™—š œžœžœ žœΟcœžœžœ˜XJ˜—šœ žœžœ˜Jš œ(‘‘‘‘‘‘‘‘‘˜;Jšœ%‘ ˜.Jšœ žœ‘˜-Jšœ(‘#˜KJš œ)‘‘‘‘‘‘‘‘‘˜LJšœ)‘!˜JJšœ‘)˜EJšœžœžœ‘˜/Jšœžœžœ‘˜:J˜—šŸœžœ˜ Jšœžœ˜Jšœ žœžœžœ˜Jšœžœ˜Jšœ%žœ˜)Jšœ žœžœžœ˜Jšžœžœ ˜JšœΟsœ1™OJšœ4’œ ™@Jšœ’œL™^Jšœ’œ6™IJ˜—šŸœžœžœ ˜J™J˜—šŸœžœžœžœ˜0J™?J˜—šΠbnœžœžœ ˜J™5J˜——Jšžœ˜J˜J˜—…—. ;