Well... interesting.  I wonder why cat acts that way.  Interestingly, I'd
played around with FIFOs some time ago, and there's a fine way to cheat:
"tail -f".

k...@minastirith:~$ mknod /tmp/FIFO p
k...@minastirith:~$ tail -f /tmp/FIFO > /tmp/FIFO.log &
[1] 13082
k...@minastirith:~$ date > /tmp/FIFO
k...@minastirith:~$ date > /tmp/FIFO
k...@minastirith:~$ cat /tmp/FIFO.log
Wed Jul 14 13:22:04 EDT 2010
Wed Jul 14 13:22:07 EDT 2010

-Ken


On Wed, July 14, 2010 12:26 pm, Michael ODonnell wrote:
>

> Some years back I created a little FIFO-reader utility that can be
> used to relay data via a named pipe (FIFO) such that it keeps the output
> end of the FIFO open despite multiple opens/closes of the input end by one
> or more writers.
>
> This is necessary because the naive approach only works once, as
> illustrated here:
>
> # mknod /tmp/FIFO p           #                (could also have used
> mkfifo) # cat /tmp/FIFO &             #    Have an instance of cat waiting
> for data. [1] 25868                     #         (bash confirms
> backgrounded process) # date > /tmp/FIFO            #   1st date opens
> FIFO, writes it, closes it.
> Wed Jul 14 11:45:04 EDT 2010  # cat shows data but exits as next read() =
> 0.
> [1]- Done cat /tmp/FIFO       # (bash confirms exit of backgrounded
> process) # date > /tmp/FIFO            # 2nd date hangs - nobody reading
> the FIFO....
>
> If I had used my FIFO-reader utility instead of cat in this example
> I could have had as many instances of date (or whatever) spewing
> sequentially into the FIFO and it would have relayed everything and none of
> the writers would have blocked.
>
> I'm now working with a cantankerous old app that can't easily be
> modified and it'd be handy to have multiple sequential invocations of that
> app each spew some logging data into a FIFO (without blocking) so it could
> be processed by a single persistent instance of a filter connected to the
> output of that FIFO.  I'm therefore about to dredge up my little utility
> and put it back into service in this situation but before I do I wonder if
> anybody knows of something that's part of the standard Gnu/Linux stuff
> that already solves this problem.
>
> I thought I'd recently heard that some surprisingly complex options
> are/were being added to cat and half expected to find this behavior is now
> an option, but maybe that was just some smarta** taking a cheap-shot at
> the Gnu folks...
>
> _______________________________________________
> gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is believed to be clean.
>
>



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/

Reply via email to