[PATCH] Cygwin: pty: detect pcon-backed pty for non-Cygwin-spawned children
Johannes Schindelin
Johannes.Schindelin@gmx.de
Thu May 28 13:48:24 GMT 2026
Hi Takashi,
On Tue, 5 May 2026, Takashi Yano wrote:
> On Thu, 30 Apr 2026 15:04:04 +0000
> "Johannes Schindelin via GitGitGadget" wrote:
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
> > index 7303f7eac..ce29f4608 100644
> > --- a/winsup/cygwin/dtable.cc
> > +++ b/winsup/cygwin/dtable.cc
> > @@ -327,7 +327,17 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
> > dev.parse (myself->ctty);
> > else
> > {
> > - dev.parse (FH_CONSOLE);
> > + /* Check whether the inherited console is actually a pseudo
> > + console bridging a pty. This happens when our non-Cygwin
> > + parent was itself spawned by a Cygwin process from a pty
> > + (e.g. bash spawning git.exe which then spawns vim). In
> > + that case, connect to the pty slave instead of treating
> > + the handle as a real console. */
> > + int pcon_minor = cygwin_shared->tty.find_pcon_pty ();
> > + if (pcon_minor >= 0)
> > + dev.parse (FHDEV (DEV_PTYS_MAJOR, pcon_minor));
> > + else
> > + dev.parse (FH_CONSOLE);
> > CloseHandle (handle);
> > handle = INVALID_HANDLE_VALUE;
>
> The lines:
> CloseHandle (handle);
> handle = INVALID_HANDLE_VALUE;
> are dropped in master branch. Do you think that these two lines
> are necessary for this patch when applying this patch to cygwin
> master branch?
Those two lines are not necessary, all added code ignores the handle
entirely.
Thanks,
Johannes
More information about the Cygwin-patches
mailing list