On Jan 13, 2005, at 2:16 PM, Jim Prewett wrote:
>
>
> All,
>
> I'm trying to make a list of open files containing several files, both
> FIFOs and standard text files.
>
> When I try to open a FIFO that has no input available, CMUCL hangs
> (19A).
>
> Can someone tell me if this is a bug or a feature?
>
> Here is my test code:
>
> ;; there are 2 files
> ;; foo is a fifo created with mkfifo
> ;; bar is a standard (empty) text file
> (let ((fifo-filename "foo")
> (std-filename "bar"))
> (list
> (open std-filename) ;; this open hangs if no input on the fifo
> (open fifo-filename)) ;; this never(?) hangs
>
Opening a fifo for reading is *supposed* to block until some process
opens the fifo for writing.
If blocking is the problem, you could start a process to do the
blocking open, e.g.:
(mp:make-process (lambda ()
(with-open-file (stream "/tmp/fifo")
(do ((line (read-line stream nil nil)
(read-line stream nil nil)))
((not line))
(princ line)
(terpri))))
:name "Opening /tmp/fifo")