I was able to debug issue. It happens when 'timeout 120 ssh' is run without --foreground option for timeout and remote server is asking for password. timeout without --foreground, when run from the script will block all input from stdin, which cause ssh to hangs in the loop.
I was able to debug issue. It happens when 'timeout 120 ssh' is run without --foreground option for timeout and remote server is asking for password. timeout without --foreground, when run from the script will block all input from stdin, which cause ssh to hangs in the loop.