ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
b8c242
From c667291303bb876707d86ac3ab9ca62355bae1b3 Mon Sep 17 00:00:00 2001
b8c242
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
b8c242
Date: Tue, 16 Oct 2018 22:45:34 +0200
b8c242
Subject: [PATCH] core: consider service with no start command immediately
b8c242
 started
b8c242
b8c242
The service would always be in state == SERVICE_INACTIVE, but it needs to go
b8c242
through state == SERVICE_START so that SuccessAction/FailureAction are executed.
b8c242
b8c242
(cherry picked from commit ef5ae8e71329e43c277e6d4f983f0c0793047b94)
b8c242
b8c242
Related: #1860899
b8c242
---
b8c242
 src/core/service.c | 6 ++++++
b8c242
 1 file changed, 6 insertions(+)
b8c242
b8c242
diff --git a/src/core/service.c b/src/core/service.c
b8c242
index ae31973774..4da1c5accb 100644
b8c242
--- a/src/core/service.c
b8c242
+++ b/src/core/service.c
b8c242
@@ -2055,6 +2055,12 @@ static void service_enter_start(Service *s) {
b8c242
                         goto fail;
b8c242
                 }
b8c242
 
b8c242
+                /* We force a fake state transition here. Otherwise, the unit would go directly from
b8c242
+                 * SERVICE_DEAD to SERVICE_DEAD without SERVICE_ACTIVATING or SERVICE_ACTIVE
b8c242
+                 * inbetween. This way we can later trigger actions that depend on the state
b8c242
+                 * transition, including SuccessAction=. */
b8c242
+                service_set_state(s, SERVICE_START);
b8c242
+
b8c242
                 service_enter_start_post(s);
b8c242
                 return;
b8c242
         }