summaryrefslogtreecommitdiff
path: root/internal/worker.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-02-05 16:37:43 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-02-05 16:37:43 +0300
commit7354eeaa96e04eaec8e2a9a33801e26c88df3c68 (patch)
tree42df39c09e145a4463650b16a2f04f2154a36257 /internal/worker.zsh
parenta12f7ac8eefd47cd9b58b0ff77c576e194029a0c (diff)
workaround for a bug in sysread
There is a bug in sysread from zsh/system. It triggers in the following case: 1. zsh has been compiled with HAVE_SELECT and without HAVE_POLL. 2. sysread is called with timeout (-t). 3. the input file descriptor is valid but there is no data to read. 4. errno happens to be EINTR prior to the call to sysread. This results in an infinite loop in sysread: while ((ret = select(infd+1, (SELECT_ARG_2_T) &fds, NULL, NULL,&select_tv)) < 1) { if (errno != EINTR || errflag || retflag || breaks || contflag) break; } Here select() keeps returning 0, indicating timeout. This is not an error, so errno doesn't get set. If it was EINTR prior to the call, it stays EINTR, and the loop keeps spinning. As a workaround, powerlevel10k sets errno to ENOTTY (any value other than EINTR will do) prior to calling sysread with timeout.
Diffstat (limited to 'internal/worker.zsh')
-rw-r--r--internal/worker.zsh2
1 files changed, 2 insertions, 0 deletions
diff --git a/internal/worker.zsh b/internal/worker.zsh
index ce38af98..cca786fc 100644
--- a/internal/worker.zsh
+++ b/internal/worker.zsh
@@ -34,6 +34,7 @@ function _p9k_worker_main() {
if [[ $fd == 0 ]]; then
local buf=
while true; do
+ [[ -t 0 ]]
sysread -t 0 'buf[$#buf+1]' && continue
(( $? == 4 )) || return
[[ $buf[-1] == (|$'\x1e') ]] && break
@@ -115,6 +116,7 @@ function _p9k_worker_receive() {
local buf resp
while true; do
+ [[ -t $_p9k__worker_resp_fd ]]
sysread -t 0 -i $_p9k__worker_resp_fd 'buf[$#buf+1]' && continue
(( $? == 4 )) || return
[[ $buf == (|*$'\x1e')$'\x05'# ]] && break