[英]child timeout in fork execlp call
I have a programme where in the child ssh's into a server and executes a command and returns back. 我有一个程序,其中将子ssh放入服务器并执行命令并返回。 the parent handles the child by signal(SIGCHLD, SIG_IGN). 父母通过信号(SIGCHLD,SIG_IGN)处理孩子。 Is there a way suchthat the child will timeout if the ssh server is not responding and an ssh from the commandline and waits for the other server forever? 如果ssh服务器没有响应,并且命令行中的ssh并永远等待其他服务器,是否有办法使子进程超时?
From ssh_config(5)
: 从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. 似乎不太可能允许TCP握手花费比内核配置为等待更长的时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.