Sha256: 9c5f7d6ff25e9b9336cca6c556958bc14c194746af4df7c1d26c2d198dfbc384

Contents?: true

Size: 509 Bytes

Versions: 4

Compression:

Stored size: 509 Bytes

Contents

module Cocaine
  class CommandLine
    class ProcessRunner
      if Process.respond_to?(:spawn)

        def call(command, env = {})
          input, output = IO.pipe
          pid = spawn(env, command, :out => output)
          output.close
          result = input.read
          waitpid(pid)
          result
        end

        private

        def spawn(*args)
          Process.spawn(*args)
        end

        def waitpid(pid)
          Process.waitpid(pid)
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cocaine-0.4.2 lib/cocaine/command_line/runners/process_runner.rb
cocaine-0.4.1 lib/cocaine/command_line/runners/process_runner.rb
cocaine-0.4.0 lib/cocaine/command_line/runners/process_runner.rb
cocaine-0.3.2 lib/cocaine/command_line/runners/process_runner.rb