Re: can select with infinite timeout return 0

Andy Sloane (andude@guildsoftware.com)
Thu, 6 Aug 1998 13:42:41 -0500


On Wed, Aug 05, 1998 at 07:41:46PM -0700, Tristan Savatier wrote:

> 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).

select returns when either the timeout is reached, a filedescriptor
becomes readable or writable, or _when a signal interrupts it_. You're
using a multithreading package (pthreads, I'm assuming, although even
linuxthreads uses signals to communicate between threads if I'm not
mistaken) which delivers signals to other threads to force context
switches. That's why it only happens during multithreading. What you can
do is check errno for EINTR and repeat the select call if necessary.

Incidentally, I like mpegtv. Keep up the good work. :)

-- 
Andy Sloane
andude@guildsoftware.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