From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8yH9-0001Pl-WC for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:41:28 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8yH5-0001On-HP for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:41:27 -0500 Received: from [199.232.76.173] (port=54710 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8yH5-0001Ok-Dp for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:41:23 -0500 Received: from mx20.gnu.org ([199.232.41.8]:57945) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N8yH5-0005Zx-2U for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:41:23 -0500 Received: from mail.codesourcery.com ([38.113.113.100]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8yH2-0006Je-PO for qemu-devel@nongnu.org; Fri, 13 Nov 2009 10:41:21 -0500 Date: Fri, 13 Nov 2009 07:41:18 -0800 From: Nathan Froyd Subject: Re: [Qemu-devel] [PATCH] Don't leak file descriptors Message-ID: <20091113154118.GL31393@codesourcery.com> References: <1258125436-23759-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1258125436-23759-1-git-send-email-kwolf@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org 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? > @@ -2385,6 +2388,9 @@ static int gdbserver_open(int port) > perror("socket"); > return -1; > } > +#ifndef _WIN32 > + fcntl(fd, F_SETFD, FD_CLOEXEC); > +#endif > > /* allow fast reuse */ > val = 1; ...and ditto for using the new wrapper here. -Nathan