summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-02-06 17:13:47 +0000
committerLaurent Bercot <ska@appnovation.com>2023-02-06 17:13:47 +0000
commit5dfb72231ff7ccde35d33d992bfd589ce7bbb367 (patch)
tree13f305ea142c2bdd0dc8c662c772d17f80d3cfb4 /src
parent3ce188983bcf62a0572e9b7df44f25d7018b5e15 (diff)
downloads6-rc-5dfb72231ff7ccde35d33d992bfd589ce7bbb367.tar.xz
Update s6 dep; simplify servicedir block/unblock
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs6rc/s6rc_servicedir_block.c17
-rw-r--r--src/libs6rc/s6rc_servicedir_unblock.c14
2 files changed, 2 insertions, 29 deletions
diff --git a/src/libs6rc/s6rc_servicedir_block.c b/src/libs6rc/s6rc_servicedir_block.c
index bc85f07..4516148 100644
--- a/src/libs6rc/s6rc_servicedir_block.c
+++ b/src/libs6rc/s6rc_servicedir_block.c
@@ -1,28 +1,13 @@
/* ISC license. */
-#include <string.h>
-#include <unistd.h>
-
-#include <skalibs/posixplz.h>
-#include <skalibs/djbunix.h>
-
#include <s6/supervise.h>
#include <s6-rc/s6rc-servicedir.h>
int s6rc_servicedir_block (char const *dir)
{
- size_t dirlen = strlen(dir) ;
s6_svstatus_t status ;
- char fn[dirlen + 6] ;
if (!s6_svstatus_read(dir, &status)) return -1 ;
- memcpy(fn, dir, dirlen) ;
- memcpy(fn + dirlen, "/down", 6) ;
- if (!touch(fn)) return -1 ;
- if (s6_svc_writectl(dir, S6_SUPERVISE_CTLDIR, "O", 1) < 0)
- {
- unlink_void(fn) ;
- return -1 ;
- }
+ if (s6_svc_writectl(dir, S6_SUPERVISE_CTLDIR, "Q", 1) < 0) return -1 ;
return status.flagwantup ;
}
diff --git a/src/libs6rc/s6rc_servicedir_unblock.c b/src/libs6rc/s6rc_servicedir_unblock.c
index c1ad8ab..c79264e 100644
--- a/src/libs6rc/s6rc_servicedir_unblock.c
+++ b/src/libs6rc/s6rc_servicedir_unblock.c
@@ -1,23 +1,11 @@
/* ISC license. */
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
#include <s6/supervise.h>
#include <s6-rc/s6rc-servicedir.h>
int s6rc_servicedir_unblock (char const *dir, int h)
{
- if (h)
- {
- size_t dirlen = strlen(dir) ;
- char fn[dirlen + 6] ;
- memcpy(fn, dir, dirlen) ;
- memcpy(fn + dirlen, "/down", 6) ;
- if (unlink(fn) < 0 && errno != ENOENT) return -1 ;
- if (s6_svc_writectl(dir, S6_SUPERVISE_CTLDIR, "u", 1) < 0) return -1 ;
- }
+ if (h && s6_svc_writectl(dir, S6_SUPERVISE_CTLDIR, "U", 1) < 0) return -1 ;
return 0 ;
}