ruby-changes:51010
From: normal <ko1@a...>
Date: Sat, 21 Apr 2018 13:02:47 +0900 (JST)
Subject: [ruby-changes:51010] normal:r63217 (trunk): test/ruby/test_io.rb: add closing recycled FD test
normal 2018-04-21 13:02:41 +0900 (Sat, 21 Apr 2018) New Revision: 63217 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63217 Log: test/ruby/test_io.rb: add closing recycled FD test Followup-to: r63216 Modified files: trunk/test/ruby/test_io.rb Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 63216) +++ test/ruby/test_io.rb (revision 63217) @@ -3760,4 +3760,36 @@ __END__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L3760 con.close end end if Socket.const_defined?(:MSG_OOB) + + def test_recycled_fd_close + dot = -'.' + IO.pipe do |sig_rd, sig_wr| + noex = Thread.new do # everything right and never see exceptions :) + until sig_rd.wait_readable(0) + IO.pipe do |r, w| + th = Thread.new { r.read(1) } + w.write(dot) + assert_equal(dot, th.value) + end + end + sig_rd.read(4) + end + 1000.times do # stupid things and make exceptions: + IO.pipe do |r,w| + th = Thread.new do + begin + r.read(1) + rescue IOError => e + e + end + end + Thread.pass until th.stop? + r.close + assert_match(/stream closed/, th.value.message) + end + end + sig_wr.write 'done' + assert_equal 'done', noex.value ,'r63216' + end + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/