From 09812eb764b440651f3ff4cb5d37bd343f800560 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 22 Dec 2013 22:14:05 +0100 Subject: sd-daemon: introduce sd_watchdog_enabled() for parsing $WATCHDOG_USEC Also, introduce a new environment variable named $WATCHDOG_PID which cotnains the PID of the process that is supposed to send the keep-alive events. This is similar how $LISTEN_FDS and $LISTEN_PID work together, and protects against confusing processes further down the process tree due to inherited environment. --- src/libsystemd-bus/sd-event.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/libsystemd-bus') diff --git a/src/libsystemd-bus/sd-event.c b/src/libsystemd-bus/sd-event.c index a1baac52aa..bfc798ca6e 100644 --- a/src/libsystemd-bus/sd-event.c +++ b/src/libsystemd-bus/sd-event.c @@ -2164,17 +2164,10 @@ _public_ int sd_event_set_watchdog(sd_event *e, int b) { if (b) { struct epoll_event ev = {}; - const char *env; - env = getenv("WATCHDOG_USEC"); - if (!env) - return false; - - r = safe_atou64(env, &e->watchdog_period); - if (r < 0) + r = sd_watchdog_enabled(false, &e->watchdog_period); + if (r <= 0) return r; - if (e->watchdog_period <= 0) - return -EIO; /* Issue first ping immediately */ sd_notify(false, "WATCHDOG=1"); -- cgit v1.2.3-54-g00ecf