Navigation Menu

Skip to content

Commit

Permalink
Use IO.pipe with block
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 8, 2012
1 parent cccac5b commit 0e5fb82
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/groonga/tester.rb
Expand Up @@ -413,19 +413,9 @@ def run_groonga_gqtp(context)
end

def open_pipe
read = 0
write = 1

begin
input_pipe = IO.pipe
output_pipe = IO.pipe
yield(input_pipe[read], input_pipe[write],
output_pipe[read], output_pipe[write])
ensure
input_pipe ||= []
output_pipe ||= []
(input_pipe + output_pipe).each do |io|
io.close unless io.closed?
IO.pipe do |input_read, input_write|
IO.pipe do |output_read, output_write|
yield(input_read, input_write, output_read, output_write)
end
end
end
Expand Down

0 comments on commit 0e5fb82

Please sign in to comment.