From 612eae5e211b86160e2a58ed87c9f77bb7f5fa5e Mon Sep 17 00:00:00 2001 From: David Dollar Date: Tue, 14 Aug 2012 17:07:39 -0400 Subject: [PATCH] use a forked process to exec a run with environment --- lib/foreman/cli.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/foreman/cli.rb b/lib/foreman/cli.rb index 4566223..f64940a 100644 --- a/lib/foreman/cli.rb +++ b/lib/foreman/cli.rb @@ -75,14 +75,17 @@ class Foreman::CLI < Thor def run(*args) load_environment! - begin - process = Foreman::Process.new(args.shelljoin, :env => engine.env) - process.run - rescue Errno::EACCES - error "not executable: #{args.first}" - rescue Errno::ENOENT - error "command not found: #{args.first}" + pid = fork do + begin + engine.env.each { |k,v| ENV[k] = v } + exec args.shelljoin + rescue Errno::EACCES + error "not executable: #{args.first}" + rescue Errno::ENOENT + error "command not found: #{args.first}" + end end + Process.wait(pid) end desc "version", "Display Foreman gem version"