1.8 compatibility
This commit is contained in:
@@ -12,6 +12,10 @@ module Foreman
|
||||
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
|
||||
end
|
||||
|
||||
def self.ruby_18?
|
||||
defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
|
||||
end
|
||||
|
||||
def self.windows?
|
||||
defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/
|
||||
end
|
||||
|
||||
@@ -260,7 +260,7 @@ private
|
||||
loop do
|
||||
(IO.select(@readers.values).first || []).each do |reader|
|
||||
data = reader.gets
|
||||
output_with_mutex name_for(@readers.key(reader)), data
|
||||
output_with_mutex name_for(@readers.invert[reader]), data
|
||||
end
|
||||
end
|
||||
rescue Exception => ex
|
||||
|
||||
@@ -43,6 +43,15 @@ class Foreman::Process
|
||||
require "posix/spawn"
|
||||
POSIX::Spawn.spawn env, command, :out => output, :err => output
|
||||
end
|
||||
elsif Foreman.ruby_18?
|
||||
Dir.chdir(cwd) do
|
||||
fork do
|
||||
$stdout.reopen output
|
||||
$stderr.reopen output
|
||||
env.each { |k,v| ENV[k] = v }
|
||||
exec command
|
||||
end
|
||||
end
|
||||
else
|
||||
Dir.chdir(cwd) do
|
||||
Process.spawn env, command, :out => output, :err => output
|
||||
|
||||
Reference in New Issue
Block a user