reference: exit with non-zero code when maxchange limit is reached

Use ending of normal mode to signal a failure.
This commit is contained in:
Miroslav Lichvar 2014-04-07 18:26:16 +02:00
parent 610284dcc3
commit 93b66ac141
2 changed files with 6 additions and 4 deletions

8
main.c
View file

@ -59,7 +59,7 @@
static int initialised = 0;
/* ================================================== */
static int exit_status = 0;
static int reload = 0;
@ -80,7 +80,7 @@ delete_pidfile(void)
void
MAI_CleanupAndExit(void)
{
if (!initialised) exit(0);
if (!initialised) exit(exit_status);
if (CNF_GetDumpOnExit()) {
SRC_DumpSources();
@ -108,7 +108,7 @@ MAI_CleanupAndExit(void)
LOG_Finalise();
exit(0);
exit(exit_status);
}
/* ================================================== */
@ -157,6 +157,8 @@ reference_mode_end(int result)
{
switch (ref_mode) {
case REF_ModeNormal:
exit_status = !result;
SCH_QuitProgram();
break;
case REF_ModeInitStepSlew:
/* post_init_ntp_hook removes sources and a source call is

View file

@ -580,7 +580,7 @@ is_offset_ok(double offset)
"Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ",
offset, max_offset, !max_offset_ignore ? "exiting" : "ignored");
if (!max_offset_ignore)
SCH_QuitProgram();
end_ref_mode(0);
else if (max_offset_ignore > 0)
max_offset_ignore--;
return 0;