Cygwin doesn't handle SIGWINCH properly in Windows Terminal
Takashi Yano
takashi.yano@nifty.ne.jp
Sun Feb 14 08:43:58 GMT 2021
On Sat, 13 Feb 2021 20:39:39 +1000
Alvin Seville wrote:
> Windows build number: Win32NT 10.0.19042.0 Microsoft Windows NT 10.0.19042.0
> Windows Terminal version (if applicable): 1.5.10271.0
>
> Script to reproduce this issue:
>
> #!/usr/bin/env bashfunction outputText()
> {
> local text=$1
> local -i textLength=${#text}
>
> local -i line="$(tput lines) / 2"
> local -i col="$(tput cols) / 2 - $textLength / 2"
>
> clear
> echo -en "\e[$line;${col}H$text"
> }
> trap "outputText 'Hello world!'" SIGWINCH
>
> outputText 'Hello world!'while truedo
> :done
This is because cygwin console handles SIGWINCH when the input
messages is processed. If the process does not call either read()
or select(), SIGWINCH will not be sent. This is the long standing
problem of the implementation and hard to fix.
Therefore, I expect the following code should work, however I
have noticed it does not.
#!/usr/bin/env bash
function outputText()
{
local text=$1
local -i textLength=${#text}
local -i line="$(tput lines) / 2"
local -i col="$(tput cols) / 2 - $textLength / 2"
clear
echo -en "\e[$line;${col}H$text"
}
trap "outputText 'Hello world!'" SIGWINCH
outputText 'Hello world!'
while true
do
read # <- Call read here
done
This seems to be a bug of console code. I will submit a patch
for this issue.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
More information about the Cygwin
mailing list