bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: preventing pipe reader from existing on writer exiting


From: John Reiser
Subject: Re: preventing pipe reader from existing on writer exiting
Date: Wed, 30 Sep 2009 15:26:13 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3

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.

--




reply via email to

[Prev in Thread] Current Thread [Next in Thread]