Merge pull request #359 from zsh-users/fixes/async-bad-file-descriptor

Fixes/async bad file descriptor
This commit is contained in:
Eric Freese 2018-07-13 20:50:31 -07:00 committed by GitHub
commit b8bf86f6ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 10 deletions

View file

@ -10,8 +10,9 @@ _zsh_autosuggest_async_request() {
# If we've got a pending request, cancel it
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
# Close the file descriptor
# Close the file descriptor and remove the handler
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
# Zsh will make a new process group for the child process only if job
# control is enabled (MONITOR option)
@ -49,10 +50,14 @@ _zsh_autosuggest_async_request() {
# First arg will be fd ready for reading
# Second arg will be passed in case of error
_zsh_autosuggest_async_response() {
# Read everything from the fd and give it as a suggestion
zle autosuggest-suggest -- "$(cat <&$1)"
if [[ -z "$2" || "$2" == "hup" ]]; then
# Read everything from the fd and give it as a suggestion
zle autosuggest-suggest -- "$(cat <&$1)"
# Remove the handler and close the fd
# Close the fd
exec {1}<&-
fi
# Always remove the handler
zle -F "$1"
exec {1}<&-
}

View file

@ -689,8 +689,9 @@ _zsh_autosuggest_async_request() {
# If we've got a pending request, cancel it
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
# Close the file descriptor
# Close the file descriptor and remove the handler
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
# Zsh will make a new process group for the child process only if job
# control is enabled (MONITOR option)
@ -728,12 +729,16 @@ _zsh_autosuggest_async_request() {
# First arg will be fd ready for reading
# Second arg will be passed in case of error
_zsh_autosuggest_async_response() {
# Read everything from the fd and give it as a suggestion
zle autosuggest-suggest -- "$(cat <&$1)"
if [[ -z "$2" || "$2" == "hup" ]]; then
# Read everything from the fd and give it as a suggestion
zle autosuggest-suggest -- "$(cat <&$1)"
# Remove the handler and close the fd
# Close the fd
exec {1}<&-
fi
# Always remove the handler
zle -F "$1"
exec {1}<&-
}
#--------------------------------------------------------------------#