From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1Taa-0002bY-KH for qemu-devel@nongnu.org; Tue, 05 May 2009 18:58:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1TaV-0002bM-9v for qemu-devel@nongnu.org; Tue, 05 May 2009 18:58:15 -0400 Received: from [199.232.76.173] (port=60845 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1TaV-0002bJ-42 for qemu-devel@nongnu.org; Tue, 05 May 2009 18:58:11 -0400 Received: from mail2.shareable.org ([80.68.89.115]:38237) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M1TaU-0008D6-JI for qemu-devel@nongnu.org; Tue, 05 May 2009 18:58:10 -0400 Date: Tue, 5 May 2009 23:58:09 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] [PATCH] linux-user: implement pipe2 syscall Message-ID: <20090505225809.GJ7574@shareable.org> References: <20090505133048.GA29646@kos.to> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090505133048.GA29646@kos.to> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Riku Voipio Cc: qemu-devel@nongnu.org Riku Voipio wrote: > implement pipe2 syscall. instead of calling pipe2 directly > (which was introduced in 2.6.27), emulate the flag functionality > with fcntl. This is wrong with multiple threads if the flag contains FD_CLOEXEC. If that situation is possible, please don't do this. 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. If you can't guarantee that, it's better to return ENOSYS as every application using pipe2() like this has a fallback to use pipe() and FD_CLOEXEC itself, and probably has application logic to protect against the race condition. If there's only one thread, or if you can arrange to block any concurrent clone/fork/execve calls in other threads (in QEMU) during the race window, then it's fine to emulate it with fcntl. -- Jamie