misc/155606: select() does not return EBADF on closed file
steuer at unixsystems.de
Wed Mar 16 14:50:08 UTC 2011
>Synopsis: select() does not return EBADF on closed file descriptor
>Arrival-Date: Wed Mar 16 14:50:08 UTC 2011
>Originator: Heribert Steuer
FreeBSD opusv2p.lr.invalid 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010 root at almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
I have tracked down a problem that came up while using the quickfix C++ library
on a FreeBSD 8.1 server.
We found that the select() system call does not return with a value < 0 and errno
set when called on a closed socket. This seems to be related to a threaded environment. Our logs stated, that this happens, whenever a thread context switch
occurs between the close() and the select() system calls.
If there is no context switch in between, select() returns -1 and errno is set
to 9. This is the expected behaviour.
The process is reproducable. Unfortunately I cannot provide example code to reproduce this scenario.
More information about the freebsd-bugs