Can't debug bash with gdb 8.2.1-1

Ken Brown kbrown@cornell.edu
Wed Jul 24 14:32:00 GMT 2019


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?

Ken

--
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



More information about the Cygwin mailing list