I have a programme where in the child ssh's into a server and executes a command and returns back. the parent handles the child by signal(SIGCHLD, SIG_IGN). Is there a way suchthat the child will timeout if the ssh server is not responding and an ssh from the comma开发者_如何学Gondline and waits for the other server forever?
From ssh_config(5)
:
ConnectTimeout
Specifies the timeout (in seconds) used when
connecting to the SSH server, instead of using the
default system TCP timeout. This value is used only
when the target is down or really unreachable, not
when it refuses the connection.
You can see it works well enough to shorten the delay:
$ time ssh -oConnectTimeout=1 ehrlichman
ssh: connect to host ehrlichman port 22: Connection timed out
real 0m1.038s
user 0m0.000s
sys 0m0.000s
$
But it may not work for increasing the delay towards forever; allowing a TCP handshake to take longer than the kernel is configured to wait seems unlikely.
精彩评论