mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-07 09:34:25 +08:00
Recursively kill dangling child processes using pgrep
This commit is contained in:
12
plug.vim
12
plug.vim
@@ -380,7 +380,17 @@ function! s:update_parallel(pull, threads)
|
|||||||
end
|
end
|
||||||
rescue Timeout::Error, Interrupt => e
|
rescue Timeout::Error, Interrupt => e
|
||||||
if fd && !fd.closed?
|
if fd && !fd.closed?
|
||||||
Process.kill 'KILL', fd.pid
|
pids = [fd.pid]
|
||||||
|
unless `which pgrep`.empty?
|
||||||
|
children = pids
|
||||||
|
while !children.empty?
|
||||||
|
children = children.map { |pid|
|
||||||
|
`pgrep -P #{pid}`.lines.map(&:chomp)
|
||||||
|
}.flatten
|
||||||
|
pids += children
|
||||||
|
end
|
||||||
|
end
|
||||||
|
pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil }
|
||||||
fd.close
|
fd.close
|
||||||
end
|
end
|
||||||
[false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"]
|
[false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"]
|
||||||
|
|||||||
Reference in New Issue
Block a user