Sha256: 2fa396fd0607ea811adcda298106847fe5332a41b8cace80b321fce526766690
Contents?: true
Size: 977 Bytes
Versions: 1
Compression:
Stored size: 977 Bytes
Contents
# coding: UTF-8 module Cocaine class CommandLine class ProcessRunner def self.available? Process.respond_to?(:spawn) end def self.supported? available? && !Cocaine::CommandLine.java? end def supported? self.class.supported? end def call(command, env = {}, options = {}) input, output = IO.pipe 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) 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cocaine-0.5.4 | lib/cocaine/command_line/runners/process_runner.rb |