[Ecls-list] RUN-PROGRAM

Juan Jose Garcia Ripoll worm at arrakis.es
Sun Jun 13 03:11:45 UTC 2004


Hi,

I just finished implementing EXT:RUN-PROGRAM, a function that allows to 
spawn child processes and send/receive data from them using pipes. Bare 
syntax:
    (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 
child process.

An example:

(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 
child.

+ Another output argument that gives the child PID, plus a function 
KILL-PROGRAM to kill spawned processes.

Regards,

Juanjo





More information about the ecl-devel mailing list