[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pipe communication

Here is a summary to realize making CLISP communicate other process
using named pipe.

Mr. Haible wrote:
   >>  (shell "mkfifo /tmp/wish-in")
   >>  (shell "mkfifo /tmp/wish-out")
   >>  (setq *lisp-to-wish-stream*
   >>	 (make-two-way-stream (open "/tmp/wish-out" :direction :input)
   >>			      (open "/tmp/wish-in" :direction :output)
   >>  ) )
   >>  (shell "wish < /tmp/wish-in > /tmp/wish-out")
   >>  (delete-file "/tmp/wish-in")
   >>  (delete-file "/tmp/wish-out")
But it doesn't work at the (open .... :input).

I got a Mr.Matthias's program which works correctly by this mailing-list,
and found differece of two programs, that is:
  1. opening named pipe for input can succeed if it has already
     connected to output of any program.
  2. Order to open two streams must be that fist output and second input.

(defun open-test nil
  (setq cmd (format NIL "program < /tmp/in > /tmp/out 2>&1 &"))
  (shell (format NIL "exec /bin/sh -c ~S" cmd))
  (setq outf (open "/tmp/in" :direction :output))
  (setq inf (open "/tmp/out" :direction :input)))

So, simple example is a above function which can succeed. 


Tomohiro Shibata (email: tom@jsk.t.u-tokyo.ac.jp)
Inoue-Inaba Laboratory,
Department of Mechano-informatics,
University of Tokyo; Japan