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