Sha256: c58868a1205d057260f04852269203f6a5ca3e21859cf799e7d728f60b21199d

Contents?: true

Size: 527 Bytes

Versions: 4

Compression:

Stored size: 527 Bytes

Contents

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

4 entries across 4 versions & 1 rubygems

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