summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-02 05:20:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-02 05:20:02 +0000
commitf0d8be4e2bac9d46126bbc43650e3a0e030da252 (patch)
tree62755414f35a418db75584cfdc381a8ec278ca38 /test
parent145ecb687200b619f58561d33cac420ba91733f3 (diff)
io.c: get rid of race condition
* io.c (rb_io_close_write): detach tied IO for writing before closing to get rid of race condition. [ruby-list:49598] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index e424747734..437e7ae5b5 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1380,6 +1380,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)