nr: #1 dodano: 2016-12-23 19:12
fifo special device (for reading), the system call blocks unless either
- the fifo is already opened by (another) process for writing OR
- you pass
open(2) - which you might not be able to do in your implementation unless you use a low level package
When you successfully opened the fifo, your
read(2) call will block until your counterparty (that opened the fifo for writing, which could be the same lisp process) writes something there.
What you are looking for is
listen (see also
(with-open-file (fifo "my-fifo" :if-does-not-exist :create)
(when (or (listen fifo)
(progn (sleep 0.1)
(format t "Read [~A]~%" (read-line fifo))))
Please note that special device handling is not necessarily equally well supported by all CL vendors.
If the above does not work, please do some experiments with the REPL: open the
fifo, see what
listen returns, write something there, see what
listen reports now, &c.
listen still returns
nil even though you already wrote something into the pipe, this might mean that your CL does not recognize the file as a special device. You might have to pass some implementation-specific arguments to
:buffering nil or something (try