From 6fee07dfc482a0069184813437a84ebd7f11a7b4 Mon Sep 17 00:00:00 2001
From: Hideo Yamauchi <renayama19661014@ybb.ne.jp>
Date: Mon, 2 Dec 2024 16:27:34 +0900
Subject: [PATCH 2/2] Mid: systemd: If the state is Pending at the time of
 probe, execute follow up monitor.

---
 daemons/execd/execd_commands.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/daemons/execd/execd_commands.c b/daemons/execd/execd_commands.c
index 8ade0ac345..ece2315e36 100644
--- a/daemons/execd/execd_commands.c
+++ b/daemons/execd/execd_commands.c
@@ -869,8 +869,16 @@ action_complete(svc_action_t * action)
             cmd->real_action = cmd->action;
             cmd->action = pcmk__str_copy(PCMK_ACTION_MONITOR);
 
-        } else if (cmd->real_action != NULL) {
-            // This is follow-up monitor to check whether start/stop completed
+        } else if (cmd->result.execution_status == PCMK_EXEC_PENDING &&
+                   pcmk__str_any_of(cmd->action, PCMK_ACTION_MONITOR, PCMK_ACTION_STATUS, NULL) &&
+                   cmd->interval_ms == 0 &&
+                   cmd->real_action == NULL) {
+            /* If the state is Pending at the time of probe, execute follow-up monitor. */
+            goagain = true;
+            cmd->real_action = cmd->action;
+            cmd->action = pcmk__str_copy(PCMK_ACTION_MONITOR);
+	} else if (cmd->real_action != NULL) {
+            // This is follow-up monitor to check whether start/stop/probe(monitor) completed
             if (cmd->result.execution_status == PCMK_EXEC_PENDING) {
                 goagain = true;
 
-- 
2.43.0

