From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68744 invoked by alias); 25 Jul 2019 08:46:48 -0000 Mailing-List: contact cygwin-cvs-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-cvs-owner@cygwin.com Received: (qmail 68699 invoked by uid 9078); 25 Jul 2019 08:46:48 -0000 Date: Thu, 25 Jul 2019 08:46:00 -0000 Message-ID: <20190725084648.68698.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: Don't change pgid to ctty pgid under debugger X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: a13145a30d5c5e8eaf82cdf65c857a248f9b6765 X-Git-Newrev: 2232498c712acc97a38fdc297cbe53ba74d0ec2c X-SW-Source: 2019-q3/txt/msg00026.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2232498c712acc97a38fdc297cbe53ba74d0ec2c commit 2232498c712acc97a38fdc297cbe53ba74d0ec2c Author: Corinna Vinschen Date: Thu Jul 25 10:40:03 2019 +0200 Cygwin: Don't change pgid to ctty pgid under debugger _pinfo::set_ctty sets myself's pgid to the ctty pgid if the process has been started from a non-Cygwin process. This isn't the right thing to do when started from GDB. GDB starts the application via standard Windows means, not via Cygwin fork/exec, so it's treated as being a non-Cygwin parent. But we want the app running in it's own process group. So skip this step when running under a debugger Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/pinfo.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index cdbd8bd..123784e 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -554,7 +554,11 @@ _pinfo::set_ctty (fhandler_termios *fh, int flags) syscall_printf ("attaching %s sid %d, pid %d, pgid %d, tty->pgid %d, tty->sid %d", __ctty (), sid, pid, pgid, tc.getpgid (), tc.getsid ()); if (!cygwin_finished_initializing && !myself->cygstarted - && pgid == pid && tc.getpgid () && tc.getsid ()) + && pgid == pid && tc.getpgid () && tc.getsid () + /* Even GDB starts app via CreateProcess which changes cygstarted. + This results in setting the wrong pgid here, so just skip this + under debugger. */ + && !being_debugged ()) pgid = tc.getpgid (); /* May actually need to do this: