mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 18:47:29 -07:00
Use :pgroup option when starting subprocesses
This makes it easier and faster to kill spawned git processes. Repetitive `pgrep` command for collecting PIDs is no longer required. Unfortunately, :pgroup option is not supported on Ruby 1.8 so we can't remove the old implementation of `killall`.
This commit is contained in:
parent
4a96db8971
commit
308fb9bc94
23
plug.vim
23
plug.vim
@ -1003,6 +1003,22 @@ function! s:update_ruby()
|
|||||||
%["#{arg.gsub('"', '\"')}"]
|
%["#{arg.gsub('"', '\"')}"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
require 'thread'
|
||||||
|
require 'fileutils'
|
||||||
|
require 'timeout'
|
||||||
|
|
||||||
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('1.9')
|
||||||
|
def popen cmd
|
||||||
|
IO.popen(cmd, :pgroup => true)
|
||||||
|
end
|
||||||
|
def killall pid
|
||||||
|
Process.kill 'TERM', - pid rescue nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
def popen cmd
|
||||||
|
IO.popen(cmd)
|
||||||
|
end
|
||||||
def killall pid
|
def killall pid
|
||||||
pids = [pid]
|
pids = [pid]
|
||||||
unless `which pgrep 2> /dev/null`.empty?
|
unless `which pgrep 2> /dev/null`.empty?
|
||||||
@ -1016,10 +1032,7 @@ function! s:update_ruby()
|
|||||||
end
|
end
|
||||||
pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil }
|
pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
require 'thread'
|
|
||||||
require 'fileutils'
|
|
||||||
require 'timeout'
|
|
||||||
running = true
|
running = true
|
||||||
iswin = VIM::evaluate('s:is_win').to_i == 1
|
iswin = VIM::evaluate('s:is_win').to_i == 1
|
||||||
pull = VIM::evaluate('s:update.pull').to_i == 1
|
pull = VIM::evaluate('s:update.pull').to_i == 1
|
||||||
@ -1086,7 +1099,7 @@ function! s:update_ruby()
|
|||||||
File.unlink tmp rescue nil
|
File.unlink tmp rescue nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
fd = IO.popen(cmd).extend(PlugStream)
|
fd = popen(cmd).extend(PlugStream)
|
||||||
first_line = true
|
first_line = true
|
||||||
log_prob = 1.0 / nthr
|
log_prob = 1.0 / nthr
|
||||||
while line = Timeout::timeout(timeout) { fd.get_line }
|
while line = Timeout::timeout(timeout) { fd.get_line }
|
||||||
|
Loading…
Reference in New Issue
Block a user