Terminator: A Hardcore “Timeout” For Ruby Code
Terminator is a new library developed by Ara Howard and Mikel Lindsaar that solves the problem of Ruby's own "timeout" feature not actually being up to the task of terminating code. timeout is supposed to terminate the execution of a block of code if it's not finished within a certain amount of time, but due to Ruby's threading model it doesn't always work that way!
Initially, Mikel considered SystemTimer - another replacement for timeout. SystemTimer is based upon UNIX alarm signals and, for some reason, still didn't resolve the main problem (although SystemTimer has ridiculously good documentation and is clearly working well for someone). After lamenting on the Ruby-Talk mailing list, Ara Howard stepped in with a potential solution which turned into what is now Terminator.
Terminator works by starting up another Ruby instance that tracks the PID of the Ruby instance that spawned it. Windows is currently not supported.
You can install Terminator with
gem install terminator or check out the code directly from here (note: they have some weird issue with referrals, just reload the URL when you get there).