Juan Jose Garcia Ripoll
worm at arrakis.es
Sun Jun 13 03:11:45 UTC 2004
I just finished implementing EXT:RUN-PROGRAM, a function that allows to
spawn child processes and send/receive data from them using pipes. Bare
(EXT:RUN-PROGRAM command args-list &key input output error)
For :input, T means use the standard input of the parent, NIL means do
not take any input but rather bind it to /dev/null, and :STREAM means
build a stream that the parent can write to and the child can read from.
:output accepts similar arguments. :error does not accept :stream, but
you can supply :OUTPUT which means that the error messages are
redirected to standard output.
If either :input or :output had a value of :STREAM, RUN-PROGRAM outputs
a bidirectional stream with which the parent can communicate with the
(let ((stream (ext:run-program "cat" nil :input :stream :output :stream)))
(dotimes (i 10)
(format t "Sending ~d~%" i)
(print i stream)
(format t "Received ~a~%" (read stream))))
To be done:
+ A :wait argument that specifies whether the parent should wait for the
+ Another output argument that gives the child PID, plus a function
KILL-PROGRAM to kill spawned processes.
More information about the ecl-devel