delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/07/25/08:13:12

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=dCYpDhsWBYuWnveO
rB6NYCD4jpz4ZNNfNHmGMYy1aaymhZz+7w7MmA5jEwStsWQVvp/dIDd6CsbT5OM7
KCJrs4YYHXafapQ1UfKLBXXnTKNnDH8UEIOij+606R755SMssFqTzwdPWB/OXMOv
4/2GM4vTwWZZA1TtyUjKCKwM6OA=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=SQZTMrVRDXbol+eYxo8/79
C+9VM=; b=EDq66F6LYN960hnqVYgR8R2cLok5QJuS0KsNbQAqJLx/DzvbJP1OT7
Yq80x++a7nlfYNTM7JmAanMLUaXrSxFTEYRlHlSDCrA1rIFANyKn5T9Qy27exIDA
RpnB5sFsLcNT8AlT9etuoJx86pcqvWa/mf4cswq3arUYshO2fq+CA=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_05,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_JMF_BL autolearn=no version=3.3.1 spammy=8.2.1-1, sk:getpgrp, UD:getpgrp_test.c, UD:getpgrp_test.exe
X-HELO: rgout05.bt.lon5.cpcloud.co.uk
X-OWM-Source-IP: 86.158.32.11 (GB)
X-OWM-Env-Sender: jonturney AT btinternet DOT com
X-VadeSecure-score: verdict=clean score=0/300, class=clean
X-SNCR-VADESECURE: CLEAN
Subject: Re: Can't debug bash with gdb 8.2.1-1
To: The Cygwin Mailing List <cygwin AT cygwin DOT com>
References: <37d412b3-f0ff-b079-4d64-16b01898b420 AT cornell DOT edu> <73dcccf2-33a0-7608-269b-e9cb9abc2238 AT dronecode DOT org DOT uk> <10d70ba8-41a8-10e8-0ab0-5be526931de7 AT cornell DOT edu> <d4efc941-490d-135b-cfd3-ef7b25f93104 AT dronecode DOT org DOT uk> <bb19dff5-80ed-ef65-d9a8-2a359705423c AT cornell DOT edu> <69e822c7-d02c-170c-9fed-c0972df16438 AT cornell DOT edu> <cdda52b1-44a9-396d-25d6-4bdf38187f85 AT cornell DOT edu>
From: Jon Turney <jon DOT turney AT dronecode DOT org DOT uk>
Message-ID: <a7d81f28-282f-3840-a1a2-724f654c4f85@dronecode.org.uk>
Date: Thu, 25 Jul 2019 13:12:08 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
MIME-Version: 1.0
In-Reply-To: <cdda52b1-44a9-396d-25d6-4bdf38187f85@cornell.edu>

On 24/07/2019 15:42, Ken Brown wrote:
> On 7/24/2019 10:32 AM, Ken Brown wrote:
>> On 7/24/2019 8:33 AM, Ken Brown wrote:
>>> $ cat getpgrp_test.c
>>> #include <unistd.h>
>>> #include <stdio.h>
>>> #include <errno.h>
>>>
>>> int
>>> main ()
>>> {
>>>       pid_t pid = getpid ();
>>>       pid_t pgid = getpgid (0);
>>>       printf ("getpid () = %d, getpgid (0) = %d, errno = %d\n", pid, pgid, errno);
>>> }
>>>
>>> $ gcc -o getpgrp_test -Wall -g -O0 getpgrp_test.c
>>>
>>> $ ./getpgrp_test.exe
>>> getpid () = 1424, getpgid (0) = 1424, errno = 0
>>>
>>> $ gdb ./getpgrp_test.exe
>>> GNU gdb (GDB) (Cygwin 8.2.1-1) 8.2.1
>>> [...]
>>> (gdb) r
>>> Starting program: /home/kbrown/Documents/programming/misc_examples/getpgrp_test.exe
>>> [...]
>>> getpid () = 1427, getpgid (0) = -1, errno = 0
>>> [...]
>>> [Inferior 1 (process 23872) exited normally]
>>>
>>> So getpgid (0) returns -1 without setting errno.  I think this means that
>>> pinfo::init() didn't fail, but for some reason myself->pgid == -1.
>>
>> I just ran the above gdb session under strace and found several lines like this:
>>
>>       25 32828861 [main] gdb 1799 tcsetpgrp: 0 = tcsetpgrp(0, -1)
>>
>> I haven't looked at the gdb code, but doesn't this mean that gdb is trying to
>> set pgrp to -1?  If so, why?  And shouldn't tcsetpgrp return -1 with EINVAL?

Well spotted.

> I just looked at the gdb commit that Jon pointed to earlier in the thread.  It
> adds calls like this:
> 
>     result = tcsetpgrp (0, getpgid (inf->pid));
> 
> It then checks for errors and takes appropriate action.  But tcsetpgrp returns
> success.
> 
> So this all seems to boil down to the fact that Cygwin's tcsetpgrp() doesn't
> check the validity of its second argument.

Great.  Thanks very much for looking into this.

I guess I need to look into gdb to see if it's trying to use -1 due to 
some other problem, or just expects that to be ignored.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019