diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-04-11 12:50:55 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-04-11 12:50:55 +0000 |
commit | 616f70fcf6c81ca70b46951ddf605008a2848a92 (patch) | |
tree | dcc440dd5493c74ffc8283269b3bd56a55ba8292 /test | |
parent | 3b011d1a00dcad0ae960800778070ec565fcef7e (diff) | |
download | ruby-616f70fcf6c81ca70b46951ddf605008a2848a92.tar.gz |
* test/ruby/test_io.rb: Added TestIO#test_cross_thread_close_stdio
and TestIO#test_cross_thread_close_fd.
The patch was written by Eric Wong. [ruby-core:35669]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 6b8e6b58ce..3d086b3750 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1809,4 +1809,43 @@ End Process.waitpid2(pid) end end + + def test_cross_thread_close_fd + with_pipe do |r,w| + read_thread = Thread.new do + begin + r.read(1) + rescue => e + e + end + end + + sleep(0.1) until read_thread.stop? + r.close + read_thread.join + assert_kind_of(IOError, read_thread.value) + end + end + + def test_cross_thread_close_stdio + with_pipe do |r,w| + pid = fork do + $stdin.reopen(r) + r.close + read_thread = Thread.new do + begin + $stdin.read(1) + rescue => e + e + end + end + sleep(0.1) until read_thread.stop? + $stdin.close + read_thread.join + exit(IOError === read_thread.value) + end + assert Process.waitpid2(pid)[1].success? + end + rescue NotImplementedError + end end |