Sha256: 67478b2583806647bccd0c03628112458d13813b429c4c921e66f243b7dd05dd

Contents?: true

Size: 544 Bytes

Versions: 2

Compression:

Stored size: 544 Bytes

Contents

# coding: UTF-8

module Cocaine
  class CommandLine
    class PosixRunner
      if Cocaine::CommandLine.posix_spawn_available?

        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)
          POSIX::Spawn.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/posix_runner.rb
cocaine-0.5.0 lib/cocaine/command_line/runners/posix_runner.rb