Merge pull request #169 from junegunn/ruby-pgroup

Use :pgroup option when starting subprocesses
This commit is contained in:
Junegunn Choi 2015-02-17 11:52:46 +09:00
commit 77f58a3793

View File

@ -1003,6 +1003,22 @@ function! s:update_ruby()
%["#{arg.gsub('"', '\"')}"]
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
pids = [pid]
unless `which pgrep 2> /dev/null`.empty?
@ -1016,10 +1032,7 @@ function! s:update_ruby()
end
pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil }
end
require 'thread'
require 'fileutils'
require 'timeout'
end
running = true
iswin = VIM::evaluate('s:is_win').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
end
else
fd = IO.popen(cmd).extend(PlugStream)
fd = popen(cmd).extend(PlugStream)
first_line = true
log_prob = 1.0 / nthr
while line = Timeout::timeout(timeout) { fd.get_line }