Re: preventing pipe reader from existing on writer exiting
Brian J. Murrell a écrit : > > Can anyone help? Ultimately I need to do I/O through a named pipe and I > need to be able to restart the writer without restarting the reader. Have a look at socat. It solved all my FIFO problems.
Re: preventing pipe reader from existing on writer exiting
"Brian J. Murrell" writes: > But this is where (simplified) my example using cat went sideways. :-( > In my real world use, the first cat is actually mplayer and doesn't have > the option of writing to stdout instead of a named file for this > particular use of it. Perhaps you can use /dev/stdout instead. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: preventing pipe reader from existing on writer exiting
On Wed, 2009-09-30 at 23:13 +0200, Andreas Schwab wrote: > > Just make sure the write side of the pipe is not closed prematurely. Hrm. Yes, of course. John's solution of having a null writer keeping it open is one way -- which I might just use. > $ (n=0; while [ $n -lt 10 ]; do cat /dev/zero; let n=$n+1; done) > /tmp/fifo & But this is where (simplified) my example using cat went sideways. :-( In my real world use, the first cat is actually mplayer and doesn't have the option of writing to stdout instead of a named file for this particular use of it. So other than John's solution, I suppose I could still follow your advice of not having the fifo write close prematurely and insulate the writer from the fifo. I can't think of another way other than using two fifos with a cat between them. Can anyone else? FWIW, the actual process which the second cat is standing in for is oggenc and it can take stdin, if that makes it any easier. So to recap: mplayer ... /tmp/fifo & oggenc ... /tmp/fifo The mplayer may terminate prematurely and need to be restarted, ideally without oggenc knowing this. Cheers and much thanx! b. signature.asc Description: This is a digitally signed message part
Re: preventing pipe reader from existing on writer exiting
Ultimately I need to do I/O through a named pipe and I need to be able to restart the writer without restarting the reader. The reader of a fifo will not be terminated as long as there is at least one writer to the fifo. Therefore, create a second writer. For example, to hold the fifo open for one hour: sleep 3600 > /tmp/fifo & The shell forks, then opens /tmp/fifo for writing. The open() waits until there is a reader. Then the forked shell execs /bin/sleep, which waits for 3600 seconds before exiting. During that 3600 seconds the fifo is open for writing, so the system will not terminate any reader of the fifo for at least that long. --
Re: preventing pipe reader from existing on writer exiting
"Brian J. Murrell" writes: > Can anyone help? Ultimately I need to do I/O through a named pipe and I > need to be able to restart the writer without restarting the reader. Just make sure the write side of the pipe is not closed prematurely. $ (n=0; while [ $n -lt 10 ]; do cat /dev/zero; let n=$n+1; done) > /tmp/fifo & Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."