summaryrefslogtreecommitdiff
path: root/src/core/service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-22 22:14:05 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-22 22:19:03 +0100
commit09812eb764b440651f3ff4cb5d37bd343f800560 (patch)
tree75a7a86e915c814ded076cd0efc84d20018ff13b /src/core/service.c
parent565a9388f261c6e459e1726e358284ff687ec941 (diff)
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.
Diffstat (limited to 'src/core/service.c')
-rw-r--r--src/core/service.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/core/service.c b/src/core/service.c
index 87eaa29378..4eb3d9e668 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1750,7 +1750,7 @@ static int service_spawn(
if (r < 0)
goto fail;
- our_env = new0(char*, 5);
+ our_env = new0(char*, 4);
if (!our_env) {
r = -ENOMEM;
goto fail;
@@ -1768,12 +1768,6 @@ static int service_spawn(
goto fail;
}
- if (s->watchdog_usec > 0)
- if (asprintf(our_env + n_env++, "WATCHDOG_USEC=%llu", (unsigned long long) s->watchdog_usec) < 0) {
- r = -ENOMEM;
- goto fail;
- }
-
if (UNIT(s)->manager->running_as != SYSTEMD_SYSTEM)
if (asprintf(our_env + n_env++, "MANAGERPID=%lu", (unsigned long) getpid()) < 0) {
r = -ENOMEM;
@@ -1804,6 +1798,7 @@ static int service_spawn(
UNIT(s)->manager->cgroup_supported,
path,
UNIT(s)->id,
+ s->watchdog_usec,
s->type == SERVICE_IDLE ? UNIT(s)->manager->idle_pipe : NULL,
s->exec_runtime,
&pid);