[PATCH v2] Cygwin: pty: Revise code waiting for forwarding again.

Takashi Yano takashi.yano@nifty.ne.jp
Sun Jan 26 13:33:00 GMT 2020

Hi Corinna,

On Sat, 25 Jan 2020 20:38:37 +0900
Takashi Yano wrote:
> On Fri, 24 Jan 2020 12:07:30 +0100
> Corinna Vinschen wrote:
> > Too bad.  It's pretty strange that CreatePseudoConsole returns a
> > valid HPCON but then isn't ready to take input immediately.
> > 
> > > I do not come up with other implementation so far.
> > > 
> > > Let me consider a while.
> > 
> > I wonder how others solve this problem.  I see that the native OpenSSH
> > is using Sleeps, too, in their start_with_pty() function, calling
> > AttachConsole in a loop, but I'm not sure if these are related to pseudo
> > console usage.  The commit message don't explain anything there :(
> The essence of the difficulty is that we have to support both cygwin
> programs and native console apps. If we consider only of native console
> apps, any time we can use pseudo console. However, pseudo console is
> not transparent at all, so it cannot be used for cygwin programs.
> Therefore, current cygwin is switching handles to be used between
> named-pipe and pseudo console.
> However, because pseudo console has relatively long latency, if pipe
> is switched just after writing to pseudo console, the forwarding
> does not get in time. So the "wait" is needed before switching.
> I had tried WriteFile(), ReadFile() and DeviceIoControl() for
> HANDLE hConDrvReference, however, all atempts of them failed.

After much struggle, I finally found a solution.
Please look at v3 patch.

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

More information about the Cygwin-patches mailing list