View Single Post

  #2  
Old 02-23-2008, 02:26 PM
Default Re: use of select() on FIFO after it has closed

"David Mathog" wrote in message
news:fppq52$ob4$1@naig.caltech.edu...
[snip]
> In this case EOF does not indicate the end of input, that is
> triggered by a particular "End of Stream" string sent to the fifo.
>
> The question is, what is the most portable way to make the select() stop
> coming back immediately? If the application closes and reopens the FIFO
> it will go back to the original state where it will wait at the select().
> Is there a better way, perhaps using fcntl()?


The potential problem with closing and reopening the FIFO is that there is a
window between read() == 0 and close() where data written will be thrown
away.

An alternative is to open the FIFO for writing immediately after opening it
for reading, and leave both descriptors open (opening it O_RDWR may work;
the behaviour is unspecified by POSIX). This means you will never see EOF
(useful in some cases).

Alex


Reply With Quote