summaryrefslogtreecommitdiffstats
path: root/src/core/service.c
diff options
context:
space:
mode:
authorJan Klötzke <Jan.Kloetzke@preh.de>2018-03-07 14:16:49 +0100
committerLennart Poettering <lennart@poettering.net>2019-04-24 10:17:10 +0200
commit99b43caf26787ac9376e10c14f6a5bcf056f900c (patch)
treef6a5b5fa7f87664876e23bbda4641b3458765f68 /src/core/service.c
parentMerge pull request #12366 from lkundrak/lr/olpc-xo-175-keyboard (diff)
downloadsystemd-99b43caf26787ac9376e10c14f6a5bcf056f900c.tar.xz
systemd-99b43caf26787ac9376e10c14f6a5bcf056f900c.zip
core: immediately trigger watchdog action on WATCHDOG=trigger
A service might be able to detect errors by itself that may require the system to take the same action as if the service locked up. Add a WATCHDOG=trigger state change notification to sd_notify() to let the service manager know about the self-detected misery and instantly trigger the configured watchdog behaviour.
Diffstat (limited to '')
-rw-r--r--src/core/service.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/core/service.c b/src/core/service.c
index c4d8378557..56667f03e8 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3742,6 +3742,16 @@ static bool service_notify_message_authorized(Service *s, pid_t pid, char **tags
return true;
}
+static void service_force_watchdog(Service *s) {
+ if (!UNIT(s)->manager->service_watchdogs)
+ return;
+
+ log_unit_error(UNIT(s), "Watchdog request (last status: %s)!",
+ s->status_text ? s->status_text : "<unset>");
+
+ service_enter_signal(s, SERVICE_STOP_WATCHDOG, SERVICE_FAILURE_WATCHDOG);
+}
+
static void service_notify_message(
Unit *u,
const struct ucred *ucred,
@@ -3888,8 +3898,15 @@ static void service_notify_message(
}
/* Interpret WATCHDOG= */
- if (strv_find(tags, "WATCHDOG=1"))
- service_reset_watchdog(s);
+ e = strv_find_startswith(tags, "WATCHDOG=");
+ if (e) {
+ if (streq(e, "1"))
+ service_reset_watchdog(s);
+ else if (streq(e, "trigger"))
+ service_force_watchdog(s);
+ else
+ log_unit_warning(u, "Passed WATCHDOG= field is invalid, ignoring.");
+ }
e = strv_find_startswith(tags, "WATCHDOG_USEC=");
if (e) {