fix(it2check): Set timeout so read does not hang - #702
Conversation
|
Thanks for tracking this down and for the clear write-up. Two things before this can land: 1. The source of truth for this file is a different repo. 2. Fractional So on bash 3.2 the patched line prints an error to stderr on every run and A version-guarded form keeps the fast path where it is available and falls back to the old behavior otherwise: if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
while read -t 0.1 -n 10000 none; do :; done
else
while read -n 10000 none; do :; done
fiCould you re-open this against iTerm2-shell-integration with a portable form? Happy to help review it there. |
|
George, I made the pull-request from |
See GitLab Issue: gnachman/iterm2#12934
Utility it2check hangs when run as root in bash 5.2.21
Running
it2checkasrootunderbash5.2.21 hangs. Regular users can run this without a problem.I discovered this issue after upgrading a server from
Ubuntu 22.04(runningbash 5.1.16(1)-release) toUbuntu 24.04(runningbash 5.2.21(1)-release). In my.bash_profileI runit2checkto decide how to set someENVvars. Logging into the upgraded server, sessions hang. I traced the problem to:It gets stuck at line 50
while read none; do :; doneIt seems that there is issue with this in bash.
The fix for the issue is to set a timeout on the read. I also set max chars.
while read -t 0.1 -n 10000 none; do :; doneI am sending a pull request on GitHub with my changes.
My solution was inspired by: clear-stdin-before-reading
Detailed steps to reproduce the problem:
What happened:
the session hangs with no way out as
ctrl-cand other remidies are captured and ignored.What should have happened:
It returns after assessing if you are running iTerm2.