From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8yKu-0002zs-C9 for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:45:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8yKp-0002wZ-B2 for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:45:19 -0500 Received: from [199.232.76.173] (port=58835 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8yKp-0002wV-3M for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:45:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:6716) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8yKo-00068p-Ev for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:45:14 -0500 Message-ID: <4AFD7EC0.4010906@redhat.com> Date: Fri, 13 Nov 2009 16:44:00 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Don't leak file descriptors References: <1258125436-23759-1-git-send-email-kwolf@redhat.com> <20091113154118.GL31393@codesourcery.com> In-Reply-To: <20091113154118.GL31393@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nathan Froyd Cc: qemu-devel@nongnu.org Am 13.11.2009 16:41, schrieb Nathan Froyd: > On Fri, Nov 13, 2009 at 04:17:16PM +0100, Kevin Wolf wrote: >> We're leaking file descriptors to child processes. Set FD_CLOEXEC on file >> descriptors that don't need to be passed to children to stop this >> misbehaviour. >> >>> --- a/gdbstub.c >> +++ b/gdbstub.c >> @@ -2356,6 +2356,9 @@ static void gdb_accept(void) >> perror("accept"); >> return; >> } else if (fd >= 0) { >> +#ifndef _WIN32 >> + fcntl(fd, F_SETFD, FD_CLOEXEC); >> +#endif >> break; >> } >> } > > Why not just use the new accept wrapper here? gdbstub.c is also used in the Linux userspace emulator where the accept wrapper is not available. I tried to add osdep.c to the linux-user build - after all, it looked easy enough - but it ended up being too much Makefile magic. This is why I decided to go for the easy way and expand it. Kevin