int main()
{
socket sock = socket_create_and_bind_and_listen();
pthread_create( thread, sock );
close( sock );
}
So we are sharing the same socket descriptor between the main thread and the
worker thread. 'select' blocks on the descriptor. Since this is the same
process, I would expect that the two threads really are sharing the
descriptor and there isn't any copying going on.
HOWEVER, doing the close() on the socket does *not* actually close the socket
descriptor in the worker thread. That is, select() will keep waiting on the
socket as if it was still valid.
Does anybody here know why? What's the reasoning behind that and who made
that decision?