[systemd-devel] [PATCH] service: don't create extra cgroup for control process when reloading SysV service

Lukas Nykryn lnykryn at redhat.com
Mon Mar 10 07:25:51 PDT 2014


Unfortunately common practice in initscripts is to have reload as an
alias for restart (https://fedoraproject.org/wiki/Packaging:SysVInitScript).
In that case the newly started process will be killed immediately after
the reload process ends and its cgroup is destroyed.
---
 src/core/service.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/core/service.c b/src/core/service.c
index 121ddec..16d7ae0 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2272,7 +2272,15 @@ static void service_enter_reload(Service *s) {
                                   !s->root_directory_start_only,
                                   false,
                                   false,
+#ifdef HAVE_SYSV_COMPAT
+                                  /* Don't create extra cgroup for SysV services.
+                                   * Unfortunately common practice was to have reload as an alias
+                                   * for restart and we are killing the new main process, when destroying
+                                   * cgroup for the control process*/
+                                  !s->is_sysv,
+#else
                                   true,
+#endif
                                   &s->control_pid);
                 if (r < 0)
                         goto fail;
@@ -3082,7 +3090,10 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                 /* Immediately get rid of the cgroup, so that the
                  * kernel doesn't delay the cgroup empty messages for
                  * the service cgroup any longer than necessary */
-                service_kill_control_processes(s);
+#ifdef HAVE_SYSV_COMPAT
+                if (!s->is_sysv)
+#endif
+                        service_kill_control_processes(s);
 
                 if (s->control_command &&
                     s->control_command->command_next &&
-- 
1.8.5.3



More information about the systemd-devel mailing list