diff options
Diffstat (limited to 'lib/timeout.rb')
-rw-r--r-- | lib/timeout.rb | 8 |
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 |