Use POSIX::Spawn to make foreman ruby 1.8 compatible and have all specs passing.
This commit is contained in:
@@ -6,7 +6,7 @@ platform :mingw do
|
||||
gem "win32console", "~> 1.3.0"
|
||||
end
|
||||
|
||||
platform :jruby do
|
||||
platform :jruby, :ruby_18 do
|
||||
gem "posix-spawn", "~> 0.3.6"
|
||||
end
|
||||
|
||||
|
||||
@@ -52,18 +52,10 @@ class Foreman::Process
|
||||
Dir.chdir(cwd) do
|
||||
Process.spawn env, expanded_command(env), :out => output, :err => output
|
||||
end
|
||||
elsif Foreman.jruby_18?
|
||||
elsif Foreman.jruby_18? || Foreman.ruby_18?
|
||||
require "posix/spawn"
|
||||
wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
|
||||
POSIX::Spawn.spawn env, wrapped_command, :out => output, :err => output
|
||||
elsif Foreman.ruby_18?
|
||||
fork do
|
||||
$stdout.reopen output
|
||||
$stderr.reopen output
|
||||
env.each { |k,v| ENV[k] = v }
|
||||
wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
|
||||
Kernel.exec wrapped_command
|
||||
end
|
||||
else
|
||||
wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
|
||||
Process.spawn env, wrapped_command, :out => output, :err => output
|
||||
|
||||
+12
-2
@@ -36,7 +36,12 @@ end
|
||||
|
||||
def forked_foreman(args)
|
||||
rd, wr = make_pipe
|
||||
Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
|
||||
if Foreman.jruby_18? || Foreman.ruby_18?
|
||||
require 'posix/spawn'
|
||||
POSIX::Spawn.spawn({}, "bundle exec bin/foreman #{args}", :out => wr, :err => wr)
|
||||
else
|
||||
Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
|
||||
end
|
||||
wr.close
|
||||
rd.read
|
||||
end
|
||||
@@ -61,7 +66,12 @@ def fork_and_capture(&blk)
|
||||
end
|
||||
|
||||
def fork_and_get_exitstatus(args)
|
||||
pid = Process.spawn("bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
|
||||
pid = if Foreman.jruby_18? || Foreman.ruby_18?
|
||||
require 'posix/spawn'
|
||||
POSIX::Spawn.spawn({}, "bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
|
||||
else
|
||||
Process.spawn("bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
|
||||
end
|
||||
Process.wait(pid)
|
||||
$?.exitstatus
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user