lib/cocaine/command_line/runners/process_runner.rb in cocaine-0.5.3 vs lib/cocaine/command_line/runners/process_runner.rb in cocaine-0.5.4

- old
+ new

@@ -13,31 +13,36 @@ def supported? self.class.supported? end - def call(command, env = {}) + def call(command, env = {}, options = {}) input, output = IO.pipe - pid = spawn(env, command, :out => output) - output.close - result = input.read - waitpid(pid) - input.close - result + options[:out] = output + with_modified_environment(env) do + pid = spawn(env, command, options) + output.close + result = input.read + waitpid(pid) + input.close + result + end end private def spawn(*args) Process.spawn(*args) end def waitpid(pid) - begin - Process.waitpid(pid) - rescue Errno::ECHILD => e - # In JRuby, waiting on a finished pid raises. - end + Process.waitpid(pid) + rescue Errno::ECHILD + # In JRuby, waiting on a finished pid raises. + end + + def with_modified_environment(env, &block) + ClimateControl.modify(env, &block) end end end end