I want to run a task in Ruby for up to (say) 10 seconds, and kill that task if it has taken longer. This is to prevent hanging of an external process. What's the best way of implementing this? In particular, how would I write the function for_up_to_10_seconds
below?
loop do
for_up_to_10_seconds do
# something
end
end