summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2025-03-23 13:42:04 +1300
committerGitHub <noreply@github.com>2025-03-23 13:42:04 +1300
commit5f77f9bea61fb4cc8447a76e191fdfb28f076862 (patch)
tree4ddd8d69f8bac7180ed9b94aada2cbaad9c46252 /test
parenteb91c664dc0b4d69db09ae913f2d7a5ef3490d74 (diff)
Fix handling of `error`/`errno` in `io_internal_wait`. (#12961)
[Bug #21195]
Notes
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 3668085d83..255de0b0a0 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -4373,4 +4373,30 @@ __END__
end
end
end
+
+ def test_blocking_timeout
+ assert_separately([], <<~'RUBY')
+ IO.pipe do |r, w|
+ trap(:INT) do
+ w.puts "INT"
+ end
+
+ main = Thread.current
+ thread = Thread.new do
+ # Wait until the main thread has entered `$stdin.gets`:
+ Thread.pass until main.status == 'sleep'
+
+ # Cause an interrupt while handling `$stdin.gets`:
+ Process.kill :INT, $$
+ end
+
+ r.timeout = 1
+ assert_equal("INT", r.gets.chomp)
+ rescue IO::TimeoutError
+ # Ignore - some platforms don't support interrupting `gets`.
+ ensure
+ thread&.join
+ end
+ RUBY
+ end
end