From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20230 invoked by alias); 1 May 2013 14:47:31 -0000 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 Received: (qmail 20221 invoked by uid 89); 1 May 2013 14:47:31 -0000 X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_NO autolearn=ham version=3.3.1 Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 01 May 2013 14:47:30 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9A4BF2ECC9; Wed, 1 May 2013 10:47:28 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id wtx9TVwmKJTR; Wed, 1 May 2013 10:47:28 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 18FE82E38F; Wed, 1 May 2013 10:47:28 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id DB864C1780; Wed, 1 May 2013 07:47:22 -0700 (PDT) Date: Wed, 01 May 2013 14:47:00 -0000 From: Joel Brobecker To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: RFC: close-on-exec internal file descriptors Message-ID: <20130501144722.GA10034@adacore.com> References: <874njjs1aa.fsf@fleche.redhat.com> <87fw32p00e.fsf@fleche.redhat.com> <874niy6y35.fsf@fleche.redhat.com> <87d2tmsey0.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d2tmsey0.fsf@fleche.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-05/txt/msg00005.txt.bz2 Hi Tom, > Tom> 2013-01-03 Tom Tromey > > Tom> PR gdb/7912: > Tom> * Makefile.in (SFILES): Add filestuff.c > Tom> (COMMON_OBS): Add filestuff.o. > Tom> (filestuff.o): New target. > [...] Unfortunately, this is causing problems on Darwin and HP/UX, because both platforms use pipes to synchronize parent and child during the fork/exec. See for instance darwin-nat.c: /* The child must synchronize with gdb: gdb must set the exception port before the child call PTRACE_SIGEXC. We use a pipe to achieve this. FIXME: is there a lighter way ? */ static int ptrace_fds[2]; Same mechanism, and therefore problem, with HP/UX targets: /* File descriptors for pipes used as semaphores during initial startup of an inferior. */ static int inf_ttrace_pfd1[2]; static int inf_ttrace_pfd2[2]; In terms of behavior, GDB either hangs during process creation, or reports a fatal failure during one of the system calls. I don't think there is a way of opening a FD with the intention of protecting them from the close-at-exec, is there? So, the solution would seem to add an interface to setup the protection, as well as a function to remove that protection (necessary when we close the fd). What do you think? -- Joel