close(2) while accept(2) is blocked

Bakul Shah bakul at bitblocks.com
Sat Mar 30 00:03:02 UTC 2013


On Fri, 29 Mar 2013 14:30:59 PDT Carl Shapiro <carl.shapiro at gmail.com> wrote:
> 
> In other operating systems, such as Solaris and MacOS X, closing the
> descriptor causes blocked system calls to return with an error.

What happens if you select() on a socket and another thread
closes this socket?  Ideally select() should return (with
EINTR?) so that the blocking thread can some cleanup action.
And if you do that, the blocking accept() case is not really
different.

There is no point in *not* telling blocking threads that the
descriptor they're waiting on is one EBADF and nothing is
going to happen.

> It is not obvious whether there is any benefit to having the current
> blocking behaviour. 

This may need some new kernel code but IMHO this is worth fixing.


More information about the freebsd-net mailing list