Closed svenha closed 4 years ago
I don't quite understand the problem. What about simply using open-output-file on your pipe? Is there a reason that prevent you from doing that?
open-output-file
will delete the named pipe and open it as a regular file. But the named pipe is created outside the bigloo program and should be used by the bigloo program (and others). Maybe a solution could be as follows: append-output-file
tests the file type and uses the appropriate C function if it is named pipe and not a regular file.
What system calls are open-output-file
and append-output-file
using?
It uses "open".
Interesting. Here's what POSIX says about open()
: https://pubs.opengroup.org/onlinepubs/7908799/xsh/open.html
O_RDWR -- Open for reading and writing. The result is undefined if this flag is applied to a FIFO.
O_TRUNC -- If the file exists and is a regular file, and the file is successfully opened O_RDWR or O_WRONLY, its length is truncated to 0 and the mode and owner are unchanged. It will have no effect on FIFO special files or terminal device files. Its effect on other file types is implementation-dependent. The result of using O_TRUNC with O_RDONLY is undefined.
It seems to mean to open is okay to append on a fifo. Do you share this understanding?
I would assume that also. But @svenha's experience sounds like the OS does something different. Sven, which OS are you using?
@lassik , I am using Ubuntu Linux. I have a minimal example and found out that binary ports work with named pipes, but not normal ports. That is ok for me.
Terminal 1:
> mkfifo /tmp/npipe
> tail -f /tmp/npipe
Terminal 2:
> bigloo -eval '(define p (append-output-binary-file "/tmp/npipe")) (output-string p "def") (close-binary-port p)'
; shows def in Terminal 1
> bigloo -eval '(define p (append-output-file "/tmp/npipe")) (display "def" p) (close-output-port p) (quit)'
; fails
do you confirm that
bigloo -eval '(define p (openoutput-file "/tmp/npipe")) (display "def" p) (close-output-port p) (quit)'
works for you?
@manuel-serrano, yes. So, I should simply avoid append-output-file
for fifos. I close this issue now.
If I use
append-output-file
on an existing named pipe (fifo), the named pipe is just overwritten as a normal file. Can bigloo deal with named pipes?