From cde93897cdefdd7c7f66c400a61e42ceee5f6a46 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 11 Dec 2013 18:14:52 +0100 Subject: event: hook up sd-event with the service watchdog logic Adds a new call sd_event_set_watchdog() that can be used to hook up the event loop with the watchdog supervision logic of systemd. If enabled and $WATCHDOG_USEC is set the event loop will ping the invoking systemd daemon right after coming back from epoll_wait() but not more often than $WATCHDOG_USEC/4. The epoll_wait() will sleep no longer than $WATCHDOG_USEC/4*3, to make sure the service manager is called in time. This means that setting WatchdogSec= in a .service file and calling sd_event_set_watchdog() in your daemon is enough to hook it up with the watchdog logic. --- src/libsystemd-bus/test-event.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libsystemd-bus/test-event.c') diff --git a/src/libsystemd-bus/test-event.c b/src/libsystemd-bus/test-event.c index 5360d8758c..2b91eb0a73 100644 --- a/src/libsystemd-bus/test-event.c +++ b/src/libsystemd-bus/test-event.c @@ -165,6 +165,8 @@ int main(int argc, char *argv[]) { assert_se(sd_event_default(&e) >= 0); + assert_se(sd_event_set_watchdog(e, true) >= 0); + got_a = false, got_b = false, got_c = false, got_d = 0; /* Add a oneshot handler, trigger it, re-enable it, and trigger -- cgit v1.2.3-54-g00ecf