bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"read -s -n999 -t0.01 key" hangs until keypress


From: Bodo Thiesen
Subject: "read -s -n999 -t0.01 key" hangs until keypress
Date: Thu, 12 Oct 2023 12:18:19 +0200

Hello list.

The following script can be used to reproduce the problem. It seems to be
related to sub-processes terminating at the "wrong" moment. The symptom:
The script runs for some time counting up until at some moment the script
hangs in the read function. Once this happens, the timeout is no longer
respected at all. Only a keypress frees the script again.

Tested versions:
        bash-5.1.16 with readline 8.1.2
        bash-5.2.15 with readline 8.2.1

Regards, Bodo

#! /bin/bash

i=0
bug=true # With bug=false the bug disappears

while true
do
        let i=i+1
        if $bug
        then
                sleep 1 &
        fi
        echo -en "\r>>> $i"
        read -s -n999 -t0.01 key
        echo -en "\r<<< $i"
done



reply via email to

[Prev in Thread] Current Thread [Next in Thread]