diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-31 14:03:20 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-31 14:03:20 +0000 |
commit | 97a5506fd5b0559977944f6e907ae9bac3a21ca4 (patch) | |
tree | 2729b1d22cb07b9dceb4ce98acbab4ef1bee3737 /test | |
parent | 727d746eaa6389c6992d72318ec004d2681a2efc (diff) |
merge revision(s) 43112,43114,43117,43118: [Backport #8980]
* io.c (rb_io_close_read): keep fptr in write_io to be discarded, to
fix freed pointer access when it is in use by other threads, and get
rid of potential memory/fd leak.
* io.c (rb_io_close_write): detach tied IO for writing before closing
to get rid of race condition. [ruby-list:49598]
* io.c (rb_io_close_read): duplex IO should wait its child process
even after close_read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@43482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 084e42e46a..5e3a12c999 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1094,6 +1094,19 @@ class TestIO < Test::Unit::TestCase end end + def test_close_read_write_separately + bug = '[ruby-list:49598]' + (1..10).each do |i| + assert_nothing_raised(IOError, "#{bug} trying ##{i}") do + IO.popen(EnvUtil.rubybin, "r+") {|f| + th = Thread.new {f.close_write} + f.close_read + th.join + } + end + end + end + def test_pid r, w = IO.pipe assert_equal(nil, r.pid) @@ -1110,6 +1123,17 @@ class TestIO < Test::Unit::TestCase assert_raise(IOError) { pipe.pid } end + def tesst_pid_after_close_read + pid1 = pid2 = nil + IO.popen(["echo", ""], "r+") do |io| + pid1 = io.pid + io.close_read + pid2 = io.pid + end + assert_not_nil(pid1) + assert_equal(pid1, pid2) + end + def make_tempfile t = Tempfile.new("test_io") t.binmode |