mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 04:55:21 +02:00

* Remove `require 'io/wait'` as it's part of core now. * Update ruby specs using version gates. * Add note about why it's conditional.
24 lines
485 B
Ruby
24 lines
485 B
Ruby
# frozen_string_literal: true
|
|
require 'test/unit'
|
|
require '-test-/thread_fd'
|
|
|
|
class TestThreadFdClose < Test::Unit::TestCase
|
|
|
|
def test_thread_fd_close
|
|
IO.pipe do |r, w|
|
|
th = Thread.new do
|
|
begin
|
|
assert_raise(IOError) {
|
|
r.read(4)
|
|
}
|
|
ensure
|
|
w.syswrite('done')
|
|
end
|
|
end
|
|
Thread.pass until th.stop?
|
|
IO.thread_fd_close(r.fileno)
|
|
assert_equal 'done', r.read(4)
|
|
th.join
|
|
end
|
|
end
|
|
end
|