valeriyvdovin / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0217-service-don-t-create-extra-cgroup-for-control-proces.patch

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