Re: Multithread select() bug

From: Davide Libenzi
Date: Mon May 10 2004 - 17:12:08 EST

On Mon, 10 May 2004, Andre Ben Hamou wrote:

> Davide Libenzi wrote:
> > Try:
> >
> > select (socket + 1, &fds, &fds, &fds, &timeout);
> > ^^^^^
> That does work, but only as a workaround (and not a universally
> applicable one). Select *should* return upon the closure of either end
> of a socket connection that is in the read-FD-set only (unless I've
> completely misunderstood the various references).

The standard says that select should return when the operation against the
fd would not block *or* would return an error different from
would-have-blocked. The following operation on a closed fd would be an
EBADF, that fits the standard description. OTOH, MT is messy. Consider a
thread that closes the fd and immediately after open another one having
the same fd#. Bottom line is, don't do it.

- Davide

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at