From: Miroslav Lichvar Date: Mon, 7 Apr 2014 16:26:16 +0000 (+0200) Subject: reference: exit with non-zero code when maxchange limit is reached X-Git-Tag: 1.30-pre1~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93b66ac14152f75fbee524ffc447ab0a64272390;p=thirdparty%2Fchrony.git reference: exit with non-zero code when maxchange limit is reached Use ending of normal mode to signal a failure. --- diff --git a/main.c b/main.c index 7eaf63ac..5ed3adda 100644 --- a/main.c +++ b/main.c @@ -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 diff --git a/reference.c b/reference.c index 3a721b96..f757f173 100644 --- a/reference.c +++ b/reference.c @@ -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;