9fc0f6
From d09b7328c7757cebdc2fb0032361c086733bd3f7 Mon Sep 17 00:00:00 2001
9fc0f6
From: Lukas Nykryn <lnykryn@redhat.com>
9fc0f6
Date: Mon, 10 Mar 2014 15:11:29 +0100
9fc0f6
Subject: [PATCH] service: don't create extra cgroup for control process when
9fc0f6
 reloading SysV service
9fc0f6
9fc0f6
Unfortunately common practice in initscripts is to have reload as an
9fc0f6
alias for restart (https://fedoraproject.org/wiki/Packaging:SysVInitScript).
9fc0f6
In that case the newly started process will be killed immediately after
9fc0f6
the reload process ends and its cgroup is destroyed.
9fc0f6
---
9fc0f6
 src/core/service.c | 13 ++++++++++++-
9fc0f6
 1 file changed, 12 insertions(+), 1 deletion(-)
9fc0f6
9fc0f6
diff --git a/src/core/service.c b/src/core/service.c
9fc0f6
index 41e5cb5..dff5286 100644
9fc0f6
--- a/src/core/service.c
9fc0f6
+++ b/src/core/service.c
9fc0f6
@@ -2353,7 +2353,15 @@ static void service_enter_reload(Service *s) {
9fc0f6
                                   !s->root_directory_start_only,
9fc0f6
                                   false,
9fc0f6
                                   false,
9fc0f6
+#ifdef HAVE_SYSV_COMPAT
9fc0f6
+                                  /* Don't create extra cgroup for SysV services.
9fc0f6
+                                   * Unfortunately common practice was to have reload as an alias
9fc0f6
+                                   * for restart and we are killing the new main process, when destroying
9fc0f6
+                                   * cgroup for the control process*/
9fc0f6
+                                  !s->is_sysv,
9fc0f6
+#else
9fc0f6
                                   true,
9fc0f6
+#endif
9fc0f6
                                   &s->control_pid);
9fc0f6
                 if (r < 0)
9fc0f6
                         goto fail;
9fc0f6
@@ -3174,7 +3182,10 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
9fc0f6
                 /* Immediately get rid of the cgroup, so that the
9fc0f6
                  * kernel doesn't delay the cgroup empty messages for
9fc0f6
                  * the service cgroup any longer than necessary */
9fc0f6
-                service_kill_control_processes(s);
9fc0f6
+#ifdef HAVE_SYSV_COMPAT
9fc0f6
+                if (!s->is_sysv)
9fc0f6
+#endif
9fc0f6
+                        service_kill_control_processes(s);
9fc0f6
 
9fc0f6
                 if (s->control_command &&
9fc0f6
                     s->control_command->command_next &&