mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-28 15:14:51 +08:00
Kill async process by id when job control disabled
This commit is contained in:
parent
0ee5b0a5c9
commit
7ab2124904
|
@ -13,9 +13,18 @@ _zsh_autosuggest_async_request() {
|
||||||
# Close the file descriptor
|
# Close the file descriptor
|
||||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||||
|
|
||||||
# Assume the child process created a new process group and send
|
# Zsh will make a new process group for the child process only if job
|
||||||
# TERM to the group to attempt to kill all descendent processes
|
# control is enabled (MONITOR option)
|
||||||
kill -TERM -$_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
if [[ -o MONITOR ]]; then
|
||||||
|
# Send the signal to the process group to kill any processes that may
|
||||||
|
# have been forked by the suggestion strategy
|
||||||
|
kill -TERM -$_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
||||||
|
else
|
||||||
|
# Kill just the child process since it wasn't placed in a new process
|
||||||
|
# group. If the suggestion strategy forked any child processes they may
|
||||||
|
# be orphaned and left behind.
|
||||||
|
kill -TERM $_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fork a process to fetch a suggestion and open a pipe to read from it
|
# Fork a process to fetch a suggestion and open a pipe to read from it
|
||||||
|
|
|
@ -692,9 +692,18 @@ _zsh_autosuggest_async_request() {
|
||||||
# Close the file descriptor
|
# Close the file descriptor
|
||||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||||
|
|
||||||
# Assume the child process created a new process group and send
|
# Zsh will make a new process group for the child process only if job
|
||||||
# TERM to the group to attempt to kill all descendent processes
|
# control is enabled (MONITOR option)
|
||||||
kill -TERM -$_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
if [[ -o MONITOR ]]; then
|
||||||
|
# Send the signal to the process group to kill any processes that may
|
||||||
|
# have been forked by the suggestion strategy
|
||||||
|
kill -TERM -$_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
||||||
|
else
|
||||||
|
# Kill just the child process since it wasn't placed in a new process
|
||||||
|
# group. If the suggestion strategy forked any child processes they may
|
||||||
|
# be orphaned and left behind.
|
||||||
|
kill -TERM $_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fork a process to fetch a suggestion and open a pipe to read from it
|
# Fork a process to fetch a suggestion and open a pipe to read from it
|
||||||
|
|
Loading…
Reference in New Issue
Block a user