summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/timeout.rb1
-rw-r--r--test/test_timeout.rb13
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 2aad1d7465..badba9a397 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -120,6 +120,7 @@ module Timeout
requests.reject!(&:done?)
end
end
+ ThreadGroup::Default.add(watcher)
watcher.name = "Timeout stdlib thread"
watcher.thread_variable_set(:"\0__detached_thread__", true)
watcher
diff --git a/test/test_timeout.rb b/test/test_timeout.rb
index 76de38949d..2d3dd16245 100644
--- a/test/test_timeout.rb
+++ b/test/test_timeout.rb
@@ -159,4 +159,17 @@ class TestTimeout < Test::Unit::TestCase
assert_equal 'timeout', r.read
r.close
end
+
+ def test_threadgroup
+ assert_separately(%w[-rtimeout], <<-'end;')
+ tg = ThreadGroup.new
+ thr = Thread.new do
+ tg.add(Thread.current)
+ Timeout.timeout(10){}
+ end
+ thr.join
+ assert_equal [].to_s, tg.list.to_s
+ end;
+ end
+
end