Wait in foreground process until daemon is fully initialized

Exit when all sockets are ready and initstepslew command and rtc step
are completed. Also, in case of a fatal error, print the error message
and exit with a non-zero status.
This commit is contained in:
Miroslav Lichvar
2011-08-26 14:47:30 +02:00
parent 7fb50d9a3e
commit 1d2a0856b4
3 changed files with 58 additions and 5 deletions

View File

@@ -41,6 +41,8 @@ static int initialised = 0;
static int system_log = 0;
static int parent_fd = 0;
static time_t last_limited = 0;
#ifdef WINNT
@@ -154,6 +156,9 @@ LOG_Fatal_Function(LOG_Facility facility, const char *format, ...)
} else {
fprintf(stderr, "Fatal error : %s\n", buf);
}
if (parent_fd) {
write(parent_fd, buf, strlen(buf) + 1);
}
#endif
MAI_CleanupAndExit();
@@ -196,6 +201,23 @@ LOG_OpenSystemLog(void)
/* ================================================== */
void
LOG_SetParentFd(int fd)
{
parent_fd = fd;
}
/* ================================================== */
void
LOG_CloseParentFd()
{
if (parent_fd > 0)
close(parent_fd);
}
/* ================================================== */
int
LOG_RateLimited(void)
{