当没有事件的互联网连接时在 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/