From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32396 invoked by alias); 15 Feb 2017 16:02:10 -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 32188 invoked by uid 89); 15 Feb 2017 16:01:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=UD:utils.c, utilsc, utils.c, H*M:bb97 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Feb 2017 16:01:48 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6970F8FAA6; Wed, 15 Feb 2017 16:01:48 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1FG1kk1002928; Wed, 15 Feb 2017 11:01:46 -0500 Subject: Re: [PATCH v3 3/6] Share parts of gdb/inflow.c with gdbserver To: Sergio Durigan Junior , GDB Patches References: <1482464361-4068-1-git-send-email-sergiodj@redhat.com> <20170208032257.15443-1-sergiodj@redhat.com> <20170208032257.15443-4-sergiodj@redhat.com> Cc: Luis Machado From: Pedro Alves Message-ID: Date: Wed, 15 Feb 2017 16:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170208032257.15443-4-sergiodj@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-02/txt/msg00418.txt.bz2 On 02/08/2017 03:22 AM, Sergio Durigan Junior wrote: > gdb/ChangeLog: > yyyy-mm-dd Sergio Durigan Junior > > * Makefile.in (SFILES): Add "common/common-inflow.c". > (COMMON_OBS): Add "common/common-inflow.o". > * common/common-inflow.c: New file, with contents from > "gdb/inflow.c". > * inflow.c (gdb_setpgid): Move to "common/common-inflow.c". > (_initialize_inflow): Move setting of "job_control" to > "handle_job_control". > * utils.c (job_control): Delete. > > gdb/gdbserver/ChangeLog: > yyyy-mm-dd Sergio Durigan Junior > > * Makefile.in: Add rule for "common-inflow.o". > (SFILE): Add "common/common-inflow.c". > (OBS): Add "common-inflow.o". We should take the opportunity to rename the file to something that makes a more sense wrt to its contents. "inflow.c" in gdb is horribly named, I think simply due to code evolution. It used to contain, many many years ago the (from the top of the file): /* Low level interface to ptrace, for GDB when running under Unix. but everything related to low level ptrace stuff moved away, and all it was left with was the terminal/job control stuff. Maybe call it common/job-control.c or maybe something even more to the point or something like that. > diff --git a/gdb/common/common-inflow.c b/gdb/common/common-inflow.c > new file mode 100644 > index 0000000..9871b5e > --- /dev/null > +++ b/gdb/common/common-inflow.c > @@ -0,0 +1,91 @@ > +/* Low level interface to ptrace, for GDB and gdbserver when running under Unix. Please update this. The file really has nothing to do with ptrace. > + > +#include "common-defs.h" > +#include "common-terminal.h" > + > +/* Nonzero if we have job control. */ > +int job_control; > + > +/* This is here because this is where we figure out whether we (probably) > + have job control. Just using job_control only does part of it because > + setpgid or setpgrp might not exist on a system without job control. > + It might be considered misplaced (on the other hand, process groups and > + job control are closely related to ttys). This "misplaced" comment could use some updating. This is no longer next to the tty stuff. > + > + For a more clean implementation, in libiberty, put a setpgid which merely > + calls setpgrp and a setpgrp which does nothing (any system with job control > + will have one or the other). */ > + > +int > +gdb_setpgid (void) > +{ > + int retval = 0; > + > + if (job_control) > + { > +#if defined (HAVE_TERMIOS) || defined (TIOCGPGRP) > +#ifdef HAVE_SETPGID > + /* The call setpgid (0, 0) is supposed to work and mean the same > + thing as this, but on Ultrix 4.2A it fails with EPERM (and > + setpgid (getpid (), getpid ()) succeeds). */ > + retval = setpgid (getpid (), getpid ()); > +#else > +#ifdef HAVE_SETPGRP Thanks, Pedro Alves