Re: select implementation not POSIX compliant?

From: Nick Palmer
Date: Fri Aug 13 2004 - 15:37:44 EST


Manfred Spraul wrote:

> Could you post the test case for this behavior: I assume your test app
> is buggy: a select call that is executed after close returned must
> return EBADF, everything else would be a bug.

Actually Solaris and Linux are consistent in terms of the behavior of
select in this respect. I suspect that the first select is blocking the
socket from being used at all, so the second select can't tell that it
is closed.

> Regarding your main point: The return result from select/poll is
> undefined in Linux if you close a descriptor while another thread polls
> or selects it.
> This is consistent with the behavior of other Unices - for example HP UX
> kills the process if you replace a descriptor that is being polled with
> dup2.

Right, hence my feeling that select is over all fairly broken. The big
difference between Solaris and Linux though is that close will call
recv* calls to return on Solaris, and close doesn't do that on Linux.
The work around is to use shutdown on Linux before calling close. This
also works on Solaris, though it makes the recv set errno differently.

Thanks for looking at this issue,
-Nick
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/