From 09b2080ddb4aa0a1265745a5ceb65748fca72efa Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 28 Sep 2013 20:29:18 +0900 Subject: [PATCH] Recursively kill dangling child processes using pgrep --- plug.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plug.vim b/plug.vim index f70751d..18e3509 100644 --- a/plug.vim +++ b/plug.vim @@ -380,7 +380,17 @@ function! s:update_parallel(pull, threads) end rescue Timeout::Error, Interrupt => e 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 end [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"]