How to exit a process run with Ruby if it takes more than 5 seconds?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2011-01-01T12:44:29Z Indexed on 2011/01/01 12:54 UTC
Read the original article Hit count: 176

Filed under:
|
|

I'm implementing a checking system in Ruby. It runs executables with different tests. If the solution is not correct, it can take forever for it to finish with certain hard tests. That's why I want to limit the execution time to 5 seconds.

I'm using system() function to run executables:

system("./solution");

.NET has a great WaitForExit() method, what about Ruby?.

Is there a way to limit external process' execution time to 5 seconds?

Thanks

© Stack Overflow or respective owner

Related posts about ruby

Related posts about process