Joel VanderWerf wrote:

> I don't think you will get a value in status that way. Try this:
> 
> require 'timeout'
> 
> output = []
> begin
>    Timeout.timeout 5 do
>      IO.popen("ping 192.168.1.1") do |pipe|
>        while line = pipe.gets
>          output << line
>        end
>      end
>    end
> rescue TimeoutError
> end
> 
> puts output

Thanks for the correction. Actually I'm running javascript interpreter 
program called spidermonkey and it does not require storing values. 
After finished it will generate a file. However sometimes if the 
javascript code is not properly coded, or with infinite loops, the 
javascript interpreter will just hang in there waiting. So I dont want 
that to happen. Need to get it stop if it tooks more than 10 seconds.

I've tried using the timeout, and it worked. However, I've found out 
that the program's process still running in background, which in this 
case it did not terminate after the timeout. How can I stop the process 
after reaching the timeout?

-- 
Posted via http://www.ruby-forum.com/.