Re: [PATCH v4] Cygwin: pty: Do not transfer input to nat-pipe while masked
Johannes Schindelin <[email protected]> Thu, 9 Jul 2026 09:59:53 +0200 (CEST)
| Newsgroups | gmane.os.cygwin.patches |
|---|---|
| Message-ID | <[email protected]> |
Hi Takashi,
On Thu, 9 Jul 2026, Takashi Yano wrote:
> On Wed, 8 Jul 2026 17:01:47 +0200 (CEST)
> Johannes Schindelin wrote:
> >=20
> > On Wed, 8 Jul 2026, Takashi Yano wrote:
> >=20
> > > On the command "cat | non-cygwin-app", `cat` sometimes fails to read
> > > key input. This happens when `cat` starts to read input before `non-
> > > cygwin-app` configures pseudo console. This is because pipe state is
> > > switched to nat-pipe when pseudo console is configured.
> > >=20
> > > This patch prevent the pipe state from changing to nat-pipe state if
> > > some cygwin process is reading input from the cyg-pipe.
> > >=20
> > > Fixes: f20641789427 ("Cygwin: pty: Reduce unecessary input transfer.=
")
> > > Signed-off-by: Takashi Yano <[email protected]>
> > > Reviewed-by: Johannes Schindelin <[email protected]>
> > > ---
> > > v2: Release all masks owned by myself on cleanup()
> > > v3: Reverts the change that made num_reader and slave_reading shared
> > > v4: Correct what mutex shoud be acquired in mask_switch_to_nat_pipe(=
)
> >=20
> > v4 is the right shape. Taking `input_mutex` at the top matches the
> > ordering used elsewhere in the file, and because it is a named mutex t=
he
> > race is closed across processes attaching to the same tty, not just ac=
ross
> > threads.
> >=20
> > One non-blocking suggestion: As far as I can tell, the new guard is
> > correct only because every caller holds `input_mutex`. That is a non-l=
ocal
> > invariant, and a short comment above the guard would help future refac=
tors
> > preserve it.
>=20
> Thanks!
>=20
> I'll add the comment you suggested and push this patch to master and
> cygwin-3_6-branch.
Sounds good to me!
Thank you,
Johannes