From 8d96cf0ae281779711ce0e368fa51ec9bf052737 Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Tue, 13 Jun 2023 09:37:16 +1100
Subject: [PATCH] only try to stop service if the scandir is running

---
 src/lib66/exec/ssexec_reconfigure.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/lib66/exec/ssexec_reconfigure.c b/src/lib66/exec/ssexec_reconfigure.c
index d8b8ad83..b1bd0adf 100644
--- a/src/lib66/exec/ssexec_reconfigure.c
+++ b/src/lib66/exec/ssexec_reconfigure.c
@@ -79,9 +79,6 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
     if (argc < 1)
         log_usage(info->usage, "\n", info->help) ;
 
-    if ((svc_scandir_ok(info->scandir.s)) !=  1 )
-        log_diesys(LOG_EXIT_SYS,"scandir: ", info->scandir.s, " is not running") ;
-
     /** build the graph of the entire system */
     graph_build_service(&graph, ares, &areslen, info, flag) ;
 
@@ -121,7 +118,11 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
         }
     }
 
-    if (nservice) {
+    r = svc_scandir_ok(info->scandir.s) ;
+    if (r < 0)
+        log_dieusys(LOG_EXIT_SYS, "check: ", info->scandir.s) ;
+
+    if (nservice && r) {
 
         /** We need to search in every tree to stop the service
          * if the user has specified a specific tree. Therefore, remove
@@ -168,7 +169,7 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
     for (n = 0 ; n < argc ; n++)
         sanitize_source(argv[n], info) ;
 
-    if (nservice) {
+    if (nservice && r) {
 
         unsigned int m = 0 ;
         int nargc = 2 + nservice + siglen ;
-- 
GitLab