From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NA4LB-0004iS-HO for qemu-devel@nongnu.org; Mon, 16 Nov 2009 11:22:09 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NA4L7-0004gX-0w for qemu-devel@nongnu.org; Mon, 16 Nov 2009 11:22:09 -0500 Received: from [199.232.76.173] (port=52284 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NA4L6-0004gU-R4 for qemu-devel@nongnu.org; Mon, 16 Nov 2009 11:22:04 -0500 Received: from mail-yx0-f188.google.com ([209.85.210.188]:59533) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NA4L6-0006tE-HN for qemu-devel@nongnu.org; Mon, 16 Nov 2009 11:22:04 -0500 Received: by yxe26 with SMTP id 26so4698224yxe.4 for ; Mon, 16 Nov 2009 08:22:04 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <4B0149C8.7040203@redhat.com> References: <1258125436-23759-1-git-send-email-kwolf@redhat.com> <4B0149C8.7040203@redhat.com> From: Blue Swirl Date: Mon, 16 Nov 2009 18:21:44 +0200 Message-ID: Subject: Re: [Qemu-devel] [PATCH] Don't leak file descriptors Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Mon, Nov 16, 2009 at 2:47 PM, Kevin Wolf wrote: > Am 13.11.2009 22:05, schrieb Blue Swirl: >> On Fri, Nov 13, 2009 at 5:17 PM, Kevin Wolf wrote: >>> We're leaking file descriptors to child processes. Set FD_CLOEXEC on fi= le >>> descriptors that don't need to be passed to children to stop this misbe= haviour. >> >>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0c =3D accept(s, (struct sockaddr *)&addr, = &addrlen); >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0c =3D qemu_accept(s, (struct sockaddr *)&a= ddr, &addrlen); >> >> Would it be possible to improve the interface so that no casts are >> needed for the calling code? > > How exactly would you do that? The only way I see to do it would be > using void*, but I'm not sure if this really is an improvement. Instead of sockaddr_in vs. sockaddr and the lame casts in between, we could have QSockAddr which magically works. Or if we only ever use sockaddr_in, just use that.