can select with infinite timeout return 0

Tristan Savatier (tristan@mpegtv.com)
Wed, 05 Aug 1998 19:41:46 -0700


Hi,

We recently spent 2 days tracking a bug in our multithreaded
MPEG player and eventually found that it was caused by a
behavior of select that we think may be a bug.

I use 2.0.27 but our problem was also seen on Red-Hat 5.0
systems (x86).

We observed that select sometimes returns 0 even though
a NULL pointer is passed for the timeout.

According to the man page and all our books, select returns
0 only if no fd is ready when the timeout expires.
Consequently if should never return 0 if a NULL pointer is
passed for the timeout (infinite timeout).

My understanding is that with a NULL timeout, select should
never return 0. It should only return n > 0 (or -1 in case
of error or EINTR).

Is my understanding correct ? If so, is that a bug in the
kernel ?

Note: This situation only occurs in a multithreaded
environment, with at least two threads running.
One of the select fd's was a pipe with the NON_BLOCKING
flag set.

Another thing bothers me: when select returns 0,
one of the fd showed data ready (i.e. FD_ISSET(fd)
was TRUE), even though no data was immediately
available on that fd. Is that legal ? IMHO, when select returns 0,
FD_ISSET(fd) should be 0 on all the fd in the set.

Could someone comment on that ?

Please Cc any answer directly to me.

Thanks.

-- 
Regards, -- Tristan Savatier

MpegTV: http://www.mpegtv.com

- 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.altern.org/andrebalsa/doc/lkml-faq.html