From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1el2-0006qC-KR for qemu-devel@nongnu.org; Wed, 06 May 2009 06:53:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1ekx-0006ns-1m for qemu-devel@nongnu.org; Wed, 06 May 2009 06:53:47 -0400 Received: from [199.232.76.173] (port=50433 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1ekw-0006nZ-Bs for qemu-devel@nongnu.org; Wed, 06 May 2009 06:53:42 -0400 Received: from mail2.shareable.org ([80.68.89.115]:43556) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M1ekv-0000cd-Th for qemu-devel@nongnu.org; Wed, 06 May 2009 06:53:42 -0400 Date: Wed, 6 May 2009 11:53:37 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] [PATCH] linux-user: implement pipe2 syscall Message-ID: <20090506105337.GB23364@shareable.org> References: <20090505133048.GA29646@kos.to> <20090505225809.GJ7574@shareable.org> <20090506080023.GA7230@kos.to> <4A0155F6.9000801@opensuse.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A0155F6.9000801@opensuse.org> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Martin Mohring Cc: Riku Voipio , qemu-devel@nongnu.org Martin Mohring wrote: > >> The point of pipe2() with FD_CLOEXEC is to be atomic: make sure > >> another thread can never see the file descriptor with FD_CLOEXEC not set. > > > How do we want to handle if "O_CLOEXEC" is not defined on the host OS, > because kernel too old (Debian Etch, CentOS 5)? Should it then return > ENOSYS? You can emulate it on any host OS using a mutex or read-write lock: - Acquire the lock for reading before calling the hosts's open/pipe/socket/etc. - Release the lock after calling the host's fcntl to set FD_CLOEXEC. - Acquire the lock for writing around emulation of fork, exec, clone and unshare. There are ways to do it more efficiently without a lock, but I don't think they are worth bothering with here. -- Jamie