From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8105 invoked by alias); 7 Dec 2008 19:26:31 -0000 Received: (qmail 8094 invoked by uid 22791); 7 Dec 2008 19:26:30 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 07 Dec 2008 19:25:55 +0000 Received: from brahms.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id mB7JPbOg022632; Sun, 7 Dec 2008 20:25:38 +0100 (CET) Received: (from kettenis@localhost) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id mB7JPbvi018021; Sun, 7 Dec 2008 20:25:37 +0100 (CET) Date: Sun, 07 Dec 2008 19:26:00 -0000 Message-Id: <200812071925.mB7JPbvi018021@brahms.sibelius.xs4all.nl> From: Mark Kettenis To: tromey@redhat.com CC: gdb-patches@sourceware.org In-reply-to: (message from Tom Tromey on Sat, 06 Dec 2008 15:05:49 -0700) Subject: Re: RFA: close-on-exec internal file descriptors References: <200812061540.mB6FemZD011819@brahms.sibelius.xs4all.nl> 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/msg00137.txt.bz2 > From: Tom Tromey > Date: Sat, 06 Dec 2008 15:05:49 -0700 > > >>>>> "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. Hmm, but that'd mean there will be thread-safety problems on platforms that don't have O_CLOEXEC (including older Linux systems). That's not good :(. Note that my suggestion to explicitly close file descriptors between fork() and exec() doesn't have thread-safety problems. > 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. I think open is used quite a bit more than fork/exec. And libraries that use fork/exec are rare. > 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. Sorry, but I fail to understand what you mean with "abstraction barrier".