[PATCH v2] Cygwin: pty: Make Ctrl-C work for non-cygwin app in GDB
Takashi Yano
takashi.yano@nifty.ne.jp
Wed Apr 15 04:42:28 GMT 2026
Hi Corinna,
Thanks for reviewing.
On Tue, 14 Apr 2026 11:04:02 +0200
Corinna Vinschen wrote:
> Hi Takashi,
>
> two (minor) points:
>
> - is_gdb_with_foreground_non_cygwin_inferior() is defined twice.
> It would probably make sense to move all these inline functions
> is_gdb_with_foreground_non_cygwin_inferior(),
> is_foreground_special_process() and
> is_non_cygwin_foreground_process() into a header.
> pinfo.h might be a good place.
Done.
> - The check in is_gdb_with_foreground_non_cygwin_inferior() looks
> a bit on the fragile side. Wouldn't it make sense to check with
> CheckRemoteDebuggerPresent(), or at least, try to?
Actually, it is not esseitial whether the child process is
being debugged. This function should check if the child process
was executed by CreateProcess() rather than exec(). For exec'ed
process, pseudo console is activated by stub process of the non-
cygwin process, however, if a cygwin process executes the child
non-cygwin process by CreateProcess(), the chance to activate
pseudo console is missing. So, pty code hooks CreateProcess()
and activates pseudo console if necessary.
Usually, this happens in GDB and strace, however, other app
may do the same.
But, checking dwProcessId == exec_dwProcessId is not rbust,
so I revised the patch to v3.
In v3 patch, _pinfo::h_debuggee_maybe is introduced and
is set in hooked CreateProcess(). Then,
cygwin_pid (GetProcessId (h_debuggee_maybe))
is checked to determine whether the process is a cygwin process.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
More information about the Cygwin-patches
mailing list