1.8 compatibility

This commit is contained in:
David Dollar
2012-07-11 15:05:28 -04:00
parent 219acaf690
commit 4b53b42be1
3 changed files with 14 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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