chiark / gitweb /
sd-daemon: introduce sd_watchdog_enabled() for parsing $WATCHDOG_USEC
[elogind.git] / src / libsystemd-bus / sd-event.c
index a1baac52aaaa324a5b372d05583d30293ad18502..bfc798ca6e91b1b558c6325179383d97fccd00d8 100644 (file)
@@ -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");