cygwin used to suppress DECRST 1049
Thomas Wolff
towo@towo.net
Fri Oct 30 14:57:06 GMT 2026
Am 30.10.2026 um 15:33 schrieb Takashi Yano:
> On Fri, 30 Oct 2026 15:14:51 +0100
> Thomas Wolff rote:
>> Am 30.10.2026 um 15:09 schrieb Takashi Yano:
>>> On Thu, 29 Oct 2026 09:53:27 +0100
>>> Thomas Wolff wrote:
>>>> Hi Takashi,
>>>>
>>>> Am 29.10.2026 um 05:11 schrieb Takashi Yano:
>>>>> Hi Thomas,
>>>>>
>>>>> On Tue, 27 Oct 2026 11:44:00 +0100
>>>>> Thomas Wolff wrote:
>>>>>> Hi,
>>>>>> see https://github.com/mintty/mintty/issues/1387#issuecomment-6140581954
>>>>>> In cygwin 3.6, apparently, while a native Windows application is
>>>>>> running, the control sequence `CSI ? 1049 l` is filtered out, with some
>>>>>> functional consequences as described in that issue. Interesting, this
>>>>>> does not apply to the corresponding DECSET sequence `CSI ? 1049 h` or to
>>>>>> similar sequences with private modes 1047 or 47.
>>>>> cygwin1.dll does not filter `CSI ? 1049 l` out, but ConPTY does.
>>>>> ConPTY drains it and handles it by itself internally. Please try
>>>>> tput smcup > smcup
>>>>> tput rmcup > rmcup
>>>>> cmd
>>>>> type smcup
>>>>> echo doing something
>>>>> type rmcup
>>>>>
>>>>>> This issue does not occur in current 3.7, so it appears to be fixed but
>>>>>> I don't see any corresponding note in the git log, so I'd still raise
>>>>>> this issue in order to make sure the fix is permanent. I see some
>>>>>> special handling of 1049 and also of 9001 in fhandler/console.cc but it
>>>>>> does not seem to have changed recently.
>>>>> If you do not encounter this in cygwin 3.7, perhaps you have OpenConsole.exe
>>>>> in /usr/bin. OpenConsole.exe does not drain that sequence and passes it
>>>>> through to the terminal.
>>>> Ah, right, thanks for pointing this out.
>>>> I've noted this in
>>>> https://github.com/mintty/mintty/issues/1387#issuecomment-6492067395.
>>>>
>>>>>> Also, in logs (mintty -l log) of the test case
>>>>>> tput smcup
>>>>>> echo doing something
>>>>>> tput rmcup > rmcup
>>>>>> cmd /C type rmcup
>>>>>> I see the Windows conhost termination control DECRST 9001 but not the
>>>>>> initial DECSET 9001. If it were present, it could possibly be used for
>>>>>> some terminal adjustment for native Windows applications or even as a
>>>>>> workaround for the above issue.
>>>>> cygwin1.dll removes CSI ? 9001 h/l from ouptput since the commit:
>>>>>
>>>>> commit b7541ef1242ac2e5d46fb1ac8704024f99042c47
>>>>> Author: Takashi Yano <takashi.yano@nifty.ne.jp>
>>>>> Date: Thu Feb 19 17:13:55 2026 +0900
>>>>>
>>>>> Cygwin: pty: Omit win32-input-mode sequence from pseudo console
>>>>>
>>>>> In Windows 11, pseudo console uses CSI?9001h which lets the terminal
>>>>> enter win32-input-mode in console. As a result, two problems happen.
>>>>>
>>>>> 1) If non-cygwin app is running in script command on the console,
>>>>> Ctrl-C terminates not only the non-cygwin app, but also script
>>>>> command without cleanup for the pseudo console.
>>>>>
>>>>> 2) Some remnants sequences from win32-input-mode occasionally
>>>>> appears on the shell in script command on the console.
>>>>>
>>>>> This patch fixes them by omit CSI?9001h to prevent the terminal
>>>>> from entering win32-input-mode.
>>>>>
>>>>> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
>>>>> Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>>>>> Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>>>> [Maybe this should be another thread...]
>>>> I guess from this commit message that DECSET 9001 may confuse the Cygwin
>>>> console but very unlike it would confuse a pty-based terminal which does
>>>> not (normally) handle the sequence.
>>>> On the other hand, I had considered to actually make use of
>>>> DECSET/DECRST 9001 in mintty in order to detect whether currently in a
>>>> Windows console application. This could be used to sanitize terminal
>>>> state in case it gets messed up by some output of the Windows program.
>>>> I noticed this in connection with my character mode test file (attached)
>>>> which switches to VGA character set mode (SGR 11), outputs a test set of
>>>> VGA characters, then switches back (SGR 10). Unfortunately, it also
>>>> contains a ^Z which is taken as EOF by `cmd /C type xvga` so the
>>>> terminal stays in VGA mode afterwards...
>>>> Another use case might be to detect WSL and adapt path conversion to it.
>>> Ok, I'd like to propose the patch which handles win32 input mode
>>> properly instead of omitting the request.
>>>
>>> Thanks.
>> Well, I'm not sure whether it's worth emulating raw keyboard input mode.
>> My request was only to pass the sequences to the terminal so it can make
>> use of them as an indication of currently running client programs.
> The patch does not introduce an emulation of raw keyboard input,
> but interprets sequences such as "\033[67;3;1;1;8;1_" as Ctrl-C
> when win32 input mode is enabled.
I don't think this is necessary as terminals will not normally generate
such sequences, unless they want to emulate Win raw keyboard themselves.
> Accordingly, CSI?9001h/l will be passed through to the terminal.
Great, thank you.
Thomas
More information about the Cygwin-developers
mailing list