From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kxrx4-00038O-5C for qemu-devel@nongnu.org; Wed, 05 Nov 2008 18:38:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kxrwz-00038C-Md for qemu-devel@nongnu.org; Wed, 05 Nov 2008 18:38:16 -0500 Received: from [199.232.76.173] (port=41469 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kxrwz-000389-HB for qemu-devel@nongnu.org; Wed, 05 Nov 2008 18:38:13 -0500 Received: from mail2.shareable.org ([80.68.89.115]:51151) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kxrwz-00061I-0K for qemu-devel@nongnu.org; Wed, 05 Nov 2008 18:38:13 -0500 Date: Wed, 5 Nov 2008 23:38:09 +0000 From: Jamie Lokier Subject: Re: [Qemu-devel] Re: [5578] Increase default IO timeout from 10ms to 5s Message-ID: <20081105233809.GA24989@shareable.org> References: <20081104113204.GA32125@shareable.org> <20081104.092231.-1384053398.imp@bsdimp.com> <20081105150042.GJ13630@shareable.org> <20081105.091015.232928302.imp@bsdimp.com> <4911E434.5020105@web.de> <20081105202852.GZ25523@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081105202852.GZ25523@redhat.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Daniel P. Berrange wrote: > > To be exact, it *was* possible for glibc to implement a pselect > > free of races: that is by using the same trick as your patch, > > i.e. making a pipe and adding it to select()ed fd's and mangling > > the sigmask. > > Yes & no. The trouble with glibc using pipes behind your back is that > then it creates a totally different race in threaded apps, where a FD > could be leaked to a child process between glibc opening its secret > pipe and setting the O_CLOSEXEC flag. Indeed it already suffers from > this problem with name resolving That involves wrapping every signal handler too, and because of threads, handlers would need to be wrapped all the time by a sigaction() replacement - quite a lot of cruft in libc would be required! If you're writing libc, and willing to go to such crazy lengths to implement pselect() "properly", you can fix the close-on-exec race by wrapping execve() too. Or you can avoid close-on-exec by using siglongjmp() from the wrapped signal handlers to jump out of select(), not requiring an fd at all. Unsurprisingly no libc that I know goes to these lengths. -- Jamie