[PATCH] Cygwin: console, pty: Prevent error in legacy console mode.
Thu Nov 7 00:48:00 GMT 2019
On Wed, 6 Nov 2019 09:37:11 -0700
Brian Inglis wrote:
> Is this not executed on every object creation and on every fork?
No. It is executed only in the first console object.
> If that is not the case, then legacy_console/() should be a singleton
> object/method, constructed when accessed, or in wincap, like
> has_con_24bit_colors() - is_con_legacy().
con.is_legacy is in shared_console_info which is shared among
console instances for identical console.
> When user explicitly sets TERM before starting Cygwin, or after forking, Cygwin
> does not touch it, so you should not, and perhaps the legacy console check
> should be added there:
> The <envar>TERM</envar> environment variable specifies your terminal
> type. It is automatically set to <literal>cygwin</literal> if you have
> not set it to something else.
> /* If console has 24 bit color capability, TERM=xterm-256color,
> otherwise, TERM=cygwin */
> if (!sawTERM)
> - envp[i++] = strdup (wincap.has_con_24bit_colors () ? xterm : cygterm);
> + envp[i++] = strdup (wincap.has_con_24bit_colors () &&
> !wincap.is_con_legacy() ? xterm : cygterm);
In command prompt, the new feature is disabled if legacy
console mode is enabled. However, it is still enabled in
windows terminal (preview) even if legacy console mode is
So the code I posted checks the availability by return
value of SetConsoleMode(). This needs handle to console.
Therefore, the check can not be done in wincap.
I revised the code so that TERM is set only if it was
not set when cygwin was started. Please look at v3 patch.
Takashi Yano <email@example.com>
More information about the Cygwin-patches