Sha256: 6d30e56dbcecb548a60db511113d22a319fd9b07ca8aaeeb23266fa9e12e3d7e

Contents?: true

Size: 526 Bytes

Versions: 2

Compression:

Stored size: 526 Bytes

Contents

# coding: UTF-8

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

2 entries across 2 versions & 1 rubygems

Version Path
cocaine-0.5.1 lib/cocaine/command_line/runners/process_runner.rb
cocaine-0.5.0 lib/cocaine/command_line/runners/process_runner.rb