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

---
 src/lib66/exec/ssexec_remove.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/lib66/exec/ssexec_remove.c b/src/lib66/exec/ssexec_remove.c
index 533a165f..389741a7 100644
--- a/src/lib66/exec/ssexec_remove.c
+++ b/src/lib66/exec/ssexec_remove.c
@@ -34,6 +34,7 @@
 #include <66/tree.h>
 #include <66/config.h>
 #include <66/constants.h>
+#include <66/svc.h>
 
 static void auto_remove(char const *path)
 {
@@ -172,7 +173,11 @@ int ssexec_remove(int argc, char const *const *argv, ssexec_t *info)
         ares[areslen++] = res ;
     }
 
-    if (sa.len) {
+    r = svc_scandir_ok(info->scandir.s) ;
+    if (r < 0)
+        log_dieusys(LOG_EXIT_SYS, "check: ", info->scandir.s) ;
+
+    if (sa.len && r) {
 
         pos = 0 ;
         char const *prog = PROG ;
-- 
GitLab