This is working code for Ruby 1.9.x:
require 'timeout'
pid = nil
begin
Timeout::timeout(2) {
pid = spawn("pause")
Process.wait(pid)
}
rescue Timeout::Error
begin
Process.kill("KILL",pid)
rescue
end
end
How can I do that in Ruby 1.8.x for Linux AND Windows?
Use case is to execute a system command and to kill it after a certain
time if the process does not terminate.
Thanks in advance!
···
--
Posted via http://www.ruby-forum.com/.