Welcome to little lamb

Code » anopa » commit 3f25c6c

stop: Fix not creating down file

author Olivier Brunel
2015-11-19 17:44:18 UTC
committer Olivier Brunel
2015-11-19 17:44:18 UTC
parent 86acf08395e7d7d7fcc07eab0d1cf94a362bc77c

stop: Fix not creating down file

src/libanopa/exec_longrun.c +13 -2

diff --git a/src/libanopa/exec_longrun.c b/src/libanopa/exec_longrun.c
index a17dc2e..5fc1303 100644
--- a/src/libanopa/exec_longrun.c
+++ b/src/libanopa/exec_longrun.c
@@ -22,6 +22,7 @@
 
 #include <unistd.h>
 #include <errno.h>
+#include <skalibs/djbunix.h>
 #include <skalibs/bytestr.h>
 #include <skalibs/tai.h>
 #include <skalibs/error.h>
@@ -163,14 +164,24 @@ _exec_longrun (int si, aa_mode mode)
         }
     }
 
-    if (is_start)
     {
         char buf[l_sn + 6];
 
         byte_copy (buf, l_sn, aa_service_name (s));
         byte_copy (buf + l_sn, 6, "/down");
 
-        unlink (buf);
+        if (is_start)
+            unlink (buf);
+        else
+        {
+            int fd;
+
+            fd = open_create (buf);
+            if (fd < 0)
+                aa_strerr_warnu2sys ("create down file for ", aa_service_name (s));
+            else
+                fd_close (fd);
+        }
     }
 
     if (already)