Mark Blackman wrote:
On 11 Sep 2008, at 02:12, Paul Johnson wrote:
Recently, another thirty or so pipes have been added to this group and
very occassionally I am noticing a problem whereby select will indicate
that a pipe is ready for reading and sysread will attempt to read from
the pipe, but there is actually nothing there to be read, and so the
sysread call hangs waiting for input.
the perl select docs also suggest you use the O_NONBLOCK flag for the
case you're referring to as well.
Select(), on any platform, *may* return an indication that there is data
to read when there isn't. Therefore using blocking reads with select()
*will* fail, at some point, in the manner that you describe. The busier
the system, the more likely it is to occur.
Any tutorial on the use of select() should really mandate the use of
O_NONBLOCK so that one can capture the EAGAIN/EWOULDBLOCK/EINPROGRESS
error(s) and then ignore them. If your sysread returns UNDEF, then check
for these errors in $! and just carry on, otherwise signal EOF in the
normal way.
Dirk