Cygwin doesn't handle SIGWINCH properly in Windows Terminal

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Tue Feb 16 06:20:08 GMT 2021


On 2021-02-15 22:48, Marco Atzeri via Cygwin wrote:
> On 16.02.2021 03:17, L A Walsh wrote:
>> On 2021/02/14 16:05, Takashi Yano wrote:
>>> On Sun, 14 Feb 2021 12:44:32 -0800
>>> L A Walsh wrote:
>>>> showsize () {\
>>>>   declare s=$(stty size); s="(${s// /x})"  ;\
>>>>   printf "%s" "$s${s//?/$'\b'}"       ;\
>>>> }; export -f showsize
>>>>
>>>> trap showsize SIGWINCH

>>> What do you mean by "reset LINES/COLUMNS"? I am not sure what
>>> is the behaviour diffrence in Linux and cygwin you mentioned.

>>      Actually not sure I can reproduce this now.  The only
>> thing I am noticing is that if bash is attached to /dev/pts3
>> (as in mintty), it works, but if attached to /dev/cons0 (as in
>> cmd.exe), nothing works as no signal is propagated from
>> the window resize to running program.
>>
>>      AFAIK, though, that's always been one of multiple probs in using windows 
>> cmd with a bash shell.

> maybe this is waht you are looking for:
> 
> # This causes bash to check the terminal size after every command
> # and adjusts $LINES and $COLUMNS to the correct values.
> shopt -s checkwinsize

Newer bash man pages say this is the default; set in my .bashrc so I can't tell; 
bash man pages also say COLUNS and LINES are set on SIGWINCH if interactive:

$ man bash | egrep -A1 'COLUMNS|LINES|checkwinsize'
COLUMNS	
	Used by the select compound command to determine the terminal width when
	printing selection lists. Automatically set if the checkwinsize option
	is enabled or in an interactive shell upon receipt of a SIGWINCH.
--
LINES	Used by the select compound command to determine the column length for
	printing selection lists. Automatically set if the checkwinsize option
	is enabled or in an interactive shell upon receipt of a SIGWINCH.
--
checkwinsize
	If set, bash checks the window size after each command and, if
	necessary, updates the values of LINES and COLUMNS.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]


More information about the Cygwin mailing list