From 2e5f610b7648e85afd89877cfeec2157fe607862 Mon Sep 17 00:00:00 2001 From: Patrick Hemmer Date: Tue, 26 Nov 2013 00:09:19 -0500 Subject: [PATCH] don't fork on 'run' This removes the fork when doing `foreman run`. The fork results in an unnecessary process laying around. The parent process doesn't do anything other than fork and wait for the child to exit. --- lib/foreman/cli.rb | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/foreman/cli.rb b/lib/foreman/cli.rb index 22930ab..10df570 100644 --- a/lib/foreman/cli.rb +++ b/lib/foreman/cli.rb @@ -83,22 +83,18 @@ class Foreman::CLI < Thor engine.load_procfile(procfile) end - pid = fork do - begin - engine.env.each { |k,v| ENV[k] = v } - if args.size == 1 && process = engine.process(args.first) - process.exec(:env => engine.env) - else - exec args.shelljoin - end - rescue Errno::EACCES - error "not executable: #{args.first}" - rescue Errno::ENOENT - error "command not found: #{args.first}" + begin + engine.env.each { |k,v| ENV[k] = v } + if args.size == 1 && process = engine.process(args.first) + process.exec(:env => engine.env) + else + exec args.shelljoin end + rescue Errno::EACCES + error "not executable: #{args.first}" + rescue Errno::ENOENT + error "command not found: #{args.first}" end - Process.wait(pid) - exit $?.exitstatus end desc "version", "Display Foreman gem version"