Sfoglia il codice sorgente

Recursively kill dangling child processes using pgrep

Junegunn Choi 12 anni fa
parent
commit
09b2080ddb
1 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. 11 1
      plug.vim

+ 11 - 1
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!"]