ntpdate 的退出代码是什么意思?
What do the exit codes of ntpdate mean?
运行 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 be used: 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 程序在没有活动的互联网连接时会在控制台中显示此消息:
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 be used: 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;
}