Skip to content

Commit

Permalink
IO.popen will call the close method which was overridden when given a…
Browse files Browse the repository at this point in the history
… block.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

class IO
  alias :close_orig :close
  def close
    warn "*** custom close"
    $close = :closed
    close_orig
  end
end

IO.popen("ruby -v", "r") {}

assert_equal($close, :closed)

puts :ok
}}}
  • Loading branch information
Watson1978 committed May 16, 2011
1 parent ffb2a1b commit 5acb4fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion io.c
Expand Up @@ -2437,7 +2437,7 @@ rb_io_s_popen(VALUE klass, SEL sel, int argc, VALUE *argv)

VALUE io = io_pipe_open(klass, process_name, mode);
if (rb_block_given_p()) {
return rb_ensure(rb_yield, io, rb_io_close, io);
return rb_ensure(rb_yield, io, io_close2, io);
}
return io;
}
Expand Down

0 comments on commit 5acb4fc

Please sign in to comment.