select() on FIFOs

Martynas Kunigelis (mkunigelis@alna.lt)
Thu, 24 Dec 1998 15:21:26 +0100


Hello,

I am trying to write a pseudo client/server program, where clients talk
to the server through a named pipe. In the server, I intended to have
the FIFO open in O_NONBLOCK mode, and then use select() to check when
there's data to read. However, when a client opens the communication
FIFO, writes some data to it and then closes it, all subsequent select()
calls in the server return, saying that there is data to read in the
FIFO. However, there's no data to read, and the server gets stuck in a
loop:

select() returns 1
read() returns 0

What is the correct solution? I can get it to work having the server
open() and close() the FIFO in blocking mode for each session, but this
does not appeal to me. I wish a had the Stevens book... :) (Ah, and
input multiplexing is not a problem as the clients will never write to
the FIFO concurrently).

Please CC: me on all replies, as I'm not subscribed to the list.
Thanks in advance and merry Christmas to everyone!

-Martynas

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/