[PATCH] Cygwin: console: Add code to restore console mode on close.

Takashi Yano takashi.yano@nifty.ne.jp
Tue Jan 14 01:37:00 GMT 2020


Hi Corinna, welcome back!

On Mon, 13 Jan 2020 17:25:53 +0100
Corinna Vinschen wrote:
> On Jan  2 22:17, Takashi Yano wrote:
> > - The console with 24bit color support has a problem that console
> >   mode is changed if cygwin process is executed in cmd.exe which
> >   started in cygwin shell. For example, cursor keys become not
> >   working if bash -> cmd -> true are executed in this order.
> >   This patch fixes the issue.
> 
> Is that supposed to work for deeper call trees as well?

I think so.

> I'm asking because I tried something like
> 
>   bash -> cmd -> bash -> cmd 
> 
> and it turned out that the cursor keys don't work at all in the second
> cmd, while they work fine again in the first cmd when returning to it.

The cursor key itsself works in this case. You can edit command line
by left and right arrow keys. However, history does not work in this
situation. This seems to be because the history buffers are exhausted.

The same happens if you try

cmd -> cmd -> cmd -> cmd -> ........ -> cmd

in command prompt without cygwin.

I confirmed that history works in this situation if NumberOfHistoryBuffers
is increased using SetConsoleHistoryInfo(). The default value of
NumberOfHistoryBuffers seems to be 4 in windows 10.

The history buffer seems to be consumed by any process which attached to
the same console. Therefore, the same happens by

bash -> bash -> cmd

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



More information about the Cygwin-patches mailing list