gpt4 book ai didi

linux - ntpdate 的退出代码是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-04 12:27:10 25 4
gpt4 key购买 nike

当没有事件的互联网连接时在 Linux 上运行 ntpdate 程序会在控制台中显示此消息:

Exiting, name server cannot be used: Temporary failure in name resolution

程序的退出代码是 1 就是这种情况。但是我找不到退出代码的真正含义,可以肯定地说退出代码 1 总是与上述错误相对应吗?

看看the docs对我没有帮助,它说了以下内容:

ntpdate's exit status is zero if it finds a server and updates the clock, and nonzero otherwise.

谁能给我一份所有可能的退出代码及其含义的列表?

谢谢!

最佳答案

查看 Source Code of the ntpdate program 后我想我可以回答我自己的问题。

不,退出代码 1 并不总是与错误 Exiting, name server cannot be used: Temporary failure in name resolution 相关。

在源码中搜索exit(1),找到了20个exit code为1的情况。

对于任何感兴趣的人,导致 Exiting, name server cannot use: Temporary failure in name resolution 错误消息的代码片段:

error = getaddrinfo(serv, service, &hints, &addrResult);
if (error != 0) {
/* Conduct more refined error analysis */
if (error == EAI_FAIL || error == EAI_AGAIN){
/* Name server is unusable. Exit after failing on the
first server, in order to shorten the timeout caused
by waiting for resolution of several servers */
fprintf(stderr, "Exiting, name server cannot be used: %s (%d)",
gai_strerror(error), error);
msyslog(LOG_ERR, "name server cannot be used: %s (%d)",
gai_strerror(error), error);
exit(1);
}
fprintf(stderr, "Error resolving %s: %s (%d)\n", serv,
gai_strerror(error), error);
msyslog(LOG_ERR, "Can't find host %s: %s (%d)", serv,
gai_strerror(error), error);
return;
}

关于linux - ntpdate 的退出代码是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44282282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com