Re: can select with infinite timeout return 0

Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
07 Aug 1998 11:45:55 +0200


Andy Sloane <andude@guildsoftware.com> writes:

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

But if select is interrupted it returns -1, not 0.

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"
schwab@gnu.org

- 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