On Mon, Oct 6, 2014 at 5:08 AM, Dimitris Papastamos <[hidden email]> wrote:
> I am using select(2) on a FIFO fd and monitoring
> for readability. select(2) doesn't return after the writer
> The same piece of code marks the fd as readable on Linux.
> Not sure which behaviour is correct though.
The Linux behavior is correct:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pselect.html: "A descriptor shall be considered ready for reading when a call to an
input function with O_NONBLOCK clear would not block, whether or not
the function would transfer data successfully. (The function might
return data, an end-of-file indication, or an error other than one
indicating that it is blocked, and in each of these cases the
descriptor shall be considered ready for reading.)"
Here is a better diff that passes the newly-updated regress test.
It does two extra things:
1) causes POLLHUP to be returned in revents on EOF
2) clears the EOF condition on read so when another writer
connects we don't still have an EOF pending
Ultimately we should investigate using a separate named pipe
implementation instead of trying to emulate them using sockets.
Something like the FreeBSD approach of extending sys_pipe.c to
support named pipes is probably the way to go.