From 36092ee3a087e6c37bf4efcd101b324f1ba9fada Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 27 Jun 2016 21:26:54 +0200 Subject: sd_notify (systemd status notifications) support sd_notify() is used to notify systemd of changes to the status of the process. This allows the systemd daemon to know when the process finished loading (and thus only start another program after Asterisk has finished loading). To use this, use a systemd unit with 'Type=notify' for Asterisk. This commit also adds the function ast_sd_notify(), a wrapper around sd_notify that does nothing if not built with systemd support. Also adds support for libsystemd detection in the configure script. Change-Id: Ied6a59dafd5ef331c5c7ae8f3ccd2dfc94be7811 (cherry picked from commit 07b95f7c65b7c083724f1af2b26f93cc22cad58c) --- include/asterisk/autoconfig.h.in | 3 +++ include/asterisk/io.h | 10 ++++++++++ 2 files changed, 13 insertions(+) (limited to 'include') diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in index 337878c4d..0fc13cf53 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -1012,6 +1012,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H +/* Define if your system has the SYSTEMD libraries. */ +#undef HAVE_SYSTEMD + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H diff --git a/include/asterisk/io.h b/include/asterisk/io.h index 2bddd3780..6ee8450bd 100644 --- a/include/asterisk/io.h +++ b/include/asterisk/io.h @@ -139,6 +139,16 @@ int ast_restore_tty(int fd, int oldstatus); int ast_get_termcols(int fd); +/*! + * \brief a wrapper for sd_notify(): notify systemd of any state changes. + * \param state a string that states the changes. See sd_notify(3). + * The wrapper does nothing if systemd ('s development headers) was not + * detected on the system. + * \returns >=0 on success, negative value on error. + */ +int ast_sd_notify(const char *state); + + #if defined(__cplusplus) || defined(c_plusplus) } #endif -- cgit v1.2.3