lib/cocaine/command_line/runners/posix_runner.rb in cocaine-0.5.7 vs lib/cocaine/command_line/runners/posix_runner.rb in cocaine-0.5.8
- old
+ new
@@ -16,20 +16,15 @@
def supported?
self.class.supported?
end
def call(command, env = {}, options = {})
- input, output = IO.pipe
- options[:out] = output
- pid = spawn(env, command, options)
- output.close
- result = ""
- while partial_result = input.read(8192)
- result << partial_result
+ pipe = MultiPipe.new
+ pid = spawn(env, command, options.merge(pipe.pipe_options))
+ pipe.read_and_then do
+ waitpid(pid)
end
- waitpid(pid)
- input.close
- result
+ pipe.output
end
private
def spawn(*args)