dcavalca / rpms / systemd

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