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

Takashi Yano takashi.yano@nifty.ne.jp
Sat Jan 25 11:38:00 GMT 2020


Hi Corinna,

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.

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



More information about the Cygwin-patches mailing list