public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* GDB looses pgrp setting in the terminal for debugged process after break.
@ 2021-01-26  3:14 Takashi Yano
  2021-02-05 10:34 ` Takashi Yano
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Yano @ 2021-01-26  3:14 UTC (permalink / raw)
  To: cygwin

Hi GDB maintainer,

In GDB, debugged process cannot continue execution after break
if it reads stdin.

With the following steps, cat is terminated with error.

1) Install coreutils-debuginfo package.
2) Run "gdb cat" in console (command prompt), not in mintty.
3) Enter "start" in gdb.
4) Enter "cont" in gdb.

This results in:
/usr/bin/cat: -: Input/output error

Both gdb-9.2-1 and gdb-10.1-1(TEST) have this problem.

I looked into this problem and found the cause is that the pgid
setting for /usr/bin/cat is lost after break. The following patch
for GDB source resolves the issue. In the following section,
winpid is passed to getpgid() rather than cygwin pid. Also, winpid
is passed to other POSIX system calls such as kill() elsewhere. 

--- inflow.c.orig	2020-05-24 06:10:29.000000000 +0900
+++ inflow.c	2021-01-23 17:48:27.963609500 +0900
@@ -364,11 +364,11 @@
 #ifdef HAVE_TERMIOS_H
 	  /* If we can't tell the inferior's actual process group,
 	     then restore whatever was the foreground pgrp the last
 	     time the inferior was running.  See also comments
 	     describing terminal_state::process_group.  */
-#ifdef HAVE_GETPGID
+#if defined (HAVE_GETPGID) && !defined (__CYGWIN__)
 	  result = tcsetpgrp (0, getpgid (inf->pid));
 #else
 	  result = tcsetpgrp (0, tinfo->process_group);
 #endif
 	  if (result == -1)


I hope the GDB maintainer will check it out.

Addresses: https://cygwin.com/pipermail/cygwin-patches/2021q1/011018.html

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-17 18:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26  3:14 GDB looses pgrp setting in the terminal for debugged process after break Takashi Yano
2021-02-05 10:34 ` Takashi Yano
2021-02-05 15:26   ` Takashi Yano
2021-05-02 16:16     ` Takashi Yano
2021-05-06 20:31       ` Jon Turney
2021-05-07  8:33         ` Takashi Yano
2022-01-17 18:57           ` Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).