summaryrefslogtreecommitdiff
path: root/lib/timeout.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-14 14:44:58 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-14 14:44:58 +0000
commitcef64ee0ba659231bec5d7599a4bfacca53352f3 (patch)
treee293822a56c6db9713ac2ef24fb72e868a989f41 /lib/timeout.rb
parent52f90f65668e479cd712e2e3bbd0dc80925816fe (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/timeout.rb')
-rw-r--r--lib/timeout.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 4e6f546e0c..dd7cb306cf 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -39,6 +39,12 @@ def timeout(sec)
yield sec
return true
ensure
- Thread.kill y if y.alive?
+ Thread.kill y if y and y.alive?
end
end
+
+if __FILE__ == $0
+ timeout(5) {
+ p 10
+ }
+end