]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: when a scope was abandoned, always log about processes we kill
authorLennart Poettering <lennart@poettering.net>
Wed, 20 Jul 2016 11:41:32 +0000 (13:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Jul 2016 12:35:15 +0000 (14:35 +0200)
After all, if a unit is abandoned, all processes inside of it may be considered
"left over" and are something we should better log about.

src/core/scope.c
src/core/scope.h

index 66a5058a570604539ddb0b0cf43a1ce360524ff2..b45e238974abab5ab378d35caffa6015c8e0666f 100644 (file)
@@ -248,7 +248,9 @@ static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) {
                 r = unit_kill_context(
                                 UNIT(s),
                                 &s->kill_context,
-                                state != SCOPE_STOP_SIGTERM ? KILL_KILL : KILL_TERMINATE,
+                                state != SCOPE_STOP_SIGTERM ? KILL_KILL :
+                                s->was_abandoned            ? KILL_TERMINATE_AND_LOG :
+                                                              KILL_TERMINATE,
                                 -1, -1, false);
                 if (r < 0)
                         goto fail;
@@ -369,6 +371,7 @@ static int scope_serialize(Unit *u, FILE *f, FDSet *fds) {
         assert(fds);
 
         unit_serialize_item(u, f, "state", scope_state_to_string(s->state));
+        unit_serialize_item(u, f, "was-abandoned", yes_no(s->was_abandoned));
         return 0;
 }
 
@@ -389,6 +392,14 @@ static int scope_deserialize_item(Unit *u, const char *key, const char *value, F
                 else
                         s->deserialized_state = state;
 
+        } else if (streq(key, "was-abandoned")) {
+                int k;
+
+                k = parse_boolean(value);
+                if (k < 0)
+                        log_unit_debug(u, "Failed to parse boolean value: %s", value);
+                else
+                        s->was_abandoned = k;
         } else
                 log_unit_debug(u, "Unknown serialization key: %s", key);
 
@@ -474,6 +485,7 @@ int scope_abandon(Scope *s) {
         if (!IN_SET(s->state, SCOPE_RUNNING, SCOPE_ABANDONED))
                 return -ESTALE;
 
+        s->was_abandoned = true;
         s->controller = mfree(s->controller);
 
         /* The client is no longer watching the remaining processes,
index 2dc86325c5667828332d701118520e9b9de1389c..94e9807bff6598d1e7e3fe971b5ade8acc6b45df 100644 (file)
@@ -43,6 +43,7 @@ struct Scope {
         usec_t timeout_stop_usec;
 
         char *controller;
+        bool was_abandoned;
 
         sd_event_source *timer_event_source;
 };