I'm trying to use Ruby's Timeout::timeout mechanism to abort a hanging ssh command but it doesn't seem to be working. If I slip in an infinite loop before the ssh call though, it will terminate so I know that I'm doing it right. What's the deal? Is it ssh or open3?
The code is simple enough:
require 'timeout'
require 'open3'
begin
status = Timeout::timeout(5) do
r = Open3.capture3('ssh root@192.168.1.1')
puts 'Debug 1'
end
rescue Timeout::Error
puts 'Timeout exceeded'
end
If there is any kind of prompt it will remain there indefinitely without printing either 'Timeout exceeded' or 'Debug 1'.