summaryrefslogtreecommitdiff
path: root/src/service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-02-25 01:49:10 +0100
committerLennart Poettering <lennart@poettering.net>2011-02-25 01:49:10 +0100
commit6d55002a69dea3b8d941c5c4e4fce80f371060b5 (patch)
tree7f2d957b9bf4662f6a20becc05d52284cb1ef52c /src/service.c
parentc904f64d84db8c4eebedf210ba10893f19ba05ed (diff)
service: never clean up a service that still has a process in it
Diffstat (limited to 'src/service.c')
-rw-r--r--src/service.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/service.c b/src/service.c
index e928d1a5e0..fef96e17dd 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2496,16 +2496,26 @@ static const char *service_sub_state_to_string(Unit *u) {
return service_state_to_string(SERVICE(u)->state);
}
-#ifdef HAVE_SYSV_COMPAT
static bool service_check_gc(Unit *u) {
Service *s = SERVICE(u);
assert(s);
- return !!s->sysv_path;
-}
+ /* Never clean up services that still have a process around,
+ * even if the service is formally dead. */
+ if (cgroup_good(s) > 0 ||
+ main_pid_good(s) > 0 ||
+ control_pid_good(s) > 0)
+ return true;
+
+#ifdef HAVE_SYSV_COMPAT
+ if (s->sysv_path)
+ return true;
#endif
+ return false;
+}
+
static bool service_check_snapshot(Unit *u) {
Service *s = SERVICE(u);
@@ -3317,9 +3327,7 @@ const UnitVTable service_vtable = {
.active_state = service_active_state,
.sub_state_to_string = service_sub_state_to_string,
-#ifdef HAVE_SYSV_COMPAT
.check_gc = service_check_gc,
-#endif
.check_snapshot = service_check_snapshot,
.sigchld_event = service_sigchld_event,