diff options
author | Benoit Daloze <eregontp@gmail.com> | 2022-05-15 13:43:29 +0200 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-05-19 07:19:40 +0900 |
commit | 354cd6f210c966327b1adffc0b81990827b77a0d (patch) | |
tree | 965dd10f1573c5c9db2dabdceed1fc0627da0c30 /test/test_timeout.rb | |
parent | 89fbec224d8e1fa35e82bf2712c5a5fd3dc06b83 (diff) |
[ruby/timeout] Handle Timeout + fork and add test for it
https://github.com/ruby/timeout/commit/4baee63b9b
Diffstat (limited to 'test/test_timeout.rb')
-rw-r--r-- | test/test_timeout.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_timeout.rb b/test/test_timeout.rb index 58eb8421db..76de38949d 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -139,4 +139,24 @@ class TestTimeout < Test::Unit::TestCase } assert(ok, bug11344) end + + def test_fork + omit 'fork not supported' unless Process.respond_to?(:fork) + r, w = IO.pipe + pid = fork do + r.close + begin + r = Timeout.timeout(0.01) { sleep 5 } + w.write r.inspect + rescue Timeout::Error + w.write 'timeout' + ensure + w.close + end + end + w.close + Process.wait pid + assert_equal 'timeout', r.read + r.close + end end |