From 9f5f5fa8ebf845c53b7a92557d7aec56ed820320 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 16 Sep 2014 18:02:30 +0200 Subject: [PATCH] lib: Add daemon_status() to util library. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10816 Signed-off-by: Andreas Schneider Reviewed-by: Alexander Bokovoy --- lib/util/become_daemon.c | 11 +++++++++++ lib/util/samba_util.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c index 17e0bafe160..78bebfc8309 100644 --- a/lib/util/become_daemon.c +++ b/lib/util/become_daemon.c @@ -123,3 +123,14 @@ _PUBLIC_ void daemon_ready(const char *name) DEBUG(0, ("STATUS=daemon '%s' finished starting up and ready to serve " "connections\n", name)); } + +_PUBLIC_ void daemon_status(const char *name, const char *msg) +{ + if (name == NULL) { + name = "Samba"; + } +#ifdef HAVE_SYSTEMD + sd_notifyf(0, "\nSTATUS=%s: %s", name, msg); +#endif + DEBUG(0, ("STATUS=daemon '%s' : %s", name, msg)); +} diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index a8d3cd67d34..ec939cc4753 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -852,6 +852,12 @@ _PUBLIC_ void exit_daemon(const char *msg, int error); **/ _PUBLIC_ void daemon_ready(const char *daemon); +/* + * Report the daemon status. For example if it is not ready to serve connections + * and is waiting for some event to happen. + */ +_PUBLIC_ void daemon_status(const char *name, const char *msg); + /** * @brief Get a password from the console. * -- 2.34.1