From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4594 invoked by alias); 6 Dec 2008 22:06:29 -0000 Received: (qmail 4585 invoked by uid 22791); 6 Dec 2008 22:06:29 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 06 Dec 2008 22:05:54 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mB6M5qp3007569; Sat, 6 Dec 2008 17:05:52 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mB6M5pW7013394; Sat, 6 Dec 2008 17:05:51 -0500 Received: from opsy.redhat.com (vpn-12-152.rdu.redhat.com [10.11.12.152]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mB6M5oun006346; Sat, 6 Dec 2008 17:05:50 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 913373785F7; Sat, 6 Dec 2008 15:05:49 -0700 (MST) To: Mark Kettenis Cc: gdb-patches@sourceware.org Subject: Re: RFA: close-on-exec internal file descriptors References: <200812061540.mB6FemZD011819@brahms.sibelius.xs4all.nl> From: Tom Tromey Reply-To: Tom Tromey Date: Sat, 06 Dec 2008 22:06:00 -0000 In-Reply-To: <200812061540.mB6FemZD011819@brahms.sibelius.xs4all.nl> (Mark Kettenis's message of "Sat\, 6 Dec 2008 16\:40\:48 +0100 \(CET\)") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-12/txt/msg00117.txt.bz2 >>>>> "Mark" == Mark Kettenis writes: Tom> I chose to take advantage of the new glibc flags like O_CLOEXEC when Tom> they are available. This is friendlier in the Python case -- here, Tom> gdb might have multiple threads, and the glibc flags enable us to TOM> avoid a window where a file descriptor is not marked close-on-exec. Mark> Sorry, but I don't see the point in having #ifdef O_CLOEXEC code Mark> when there is a perfectly portable way to do this using fcntl. It is better for thread safety. This matters in the Python case. Mark> It leads to more bits of code that can possibly go untested. I will try to add a test case. That will address this. Mark> I also think it would actually be better to explicitly close file Mark> descriptors before doing an exec instead of relying on people to use Mark> the proper _cloexec call throughout gdb. Why do you think this? I think that it is difficult to truly ensure reliability with either approach. We might miss an open, but so too we might miss a fork/exec. The more libraries we use, the more likely this becomes. But, since gdb and all its dependencies are free software, I think we might as well try to implement the better approach, whichever that is. In my view, close-on-exec is preferable. It better communicates the intent of the programmer, and in the library case it is an abstraction barrier. Tom