summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/s6/s6-supervise.h1
-rw-r--r--src/libs6/deps-lib/s61
-rw-r--r--src/libs6/s6_svc_ok.c25
-rw-r--r--src/supervision/deps-exe/s6-svok1
-rw-r--r--src/supervision/s6-svok.c24
5 files changed, 32 insertions, 20 deletions
diff --git a/src/include/s6/s6-supervise.h b/src/include/s6/s6-supervise.h
index dec0455..faf4e9c 100644
--- a/src/include/s6/s6-supervise.h
+++ b/src/include/s6/s6-supervise.h
@@ -12,6 +12,7 @@
#define S6_SVSTATUS_FILENAME S6_SUPERVISE_CTLDIR "/status"
#define S6_SVSTATUS_SIZE 35
+extern int s6_svc_ok (char const *) ;
extern int s6_svc_write (char const *, char const *, unsigned int) ;
extern int s6_svc_writectl (char const *, char const *, char const *, unsigned int) ;
extern int s6_svc_main (int, char const *const *, char const *, char const *, char const *) ;
diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6
index 23ca024..65062e1 100644
--- a/src/libs6/deps-lib/s6
+++ b/src/libs6/deps-lib/s6
@@ -25,6 +25,7 @@ s6_accessrules_uidgid_cdb.o
s6_accessrules_uidgid_fs.o
s6_supervise_lock.o
s6_supervise_lock_mode.o
+s6_svc_ok.o
s6_svc_write.o
s6_svc_writectl.o
s6_svstatus_pack.o
diff --git a/src/libs6/s6_svc_ok.c b/src/libs6/s6_svc_ok.c
new file mode 100644
index 0000000..37c317c
--- /dev/null
+++ b/src/libs6/s6_svc_ok.c
@@ -0,0 +1,25 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/bytestr.h>
+#include <skalibs/djbunix.h>
+#include <s6/s6-supervise.h>
+
+int s6_svc_ok (char const *dir)
+{
+ int fd ;
+ unsigned int dirlen = str_len(dir) ;
+ char fn[dirlen + 9 + sizeof(S6_SUPERVISE_CTLDIR)] ;
+ byte_copy(fn, dirlen, dir) ;
+ fn[dirlen] = '/' ;
+ byte_copy(fn + dirlen + 1, sizeof(S6_SUPERVISE_CTLDIR) - 1, S6_SUPERVISE_CTLDIR) ;
+ byte_copy(fn + dirlen + sizeof(S6_SUPERVISE_CTLDIR), 9, "/control") ;
+ fd = open_write(fn) ;
+ if (fd < 0)
+ {
+ if ((errno == ENXIO) || (errno == ENOENT)) return 0 ;
+ else return -1 ;
+ }
+ fd_close(fd) ;
+ return 1 ;
+}
diff --git a/src/supervision/deps-exe/s6-svok b/src/supervision/deps-exe/s6-svok
index e7187fe..08815d9 100644
--- a/src/supervision/deps-exe/s6-svok
+++ b/src/supervision/deps-exe/s6-svok
@@ -1 +1,2 @@
+${LIBS6}
-lskarnet
diff --git a/src/supervision/s6-svok.c b/src/supervision/s6-svok.c
index 4a615e9..176d8a8 100644
--- a/src/supervision/s6-svok.c
+++ b/src/supervision/s6-svok.c
@@ -1,32 +1,16 @@
/* ISC license. */
-#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
#include <s6/s6-supervise.h>
#define USAGE "s6-svok servicedir"
int main (int argc, char const *const *argv)
{
+ int r ;
PROG = "s6-svok" ;
if (argc < 2) strerr_dieusage(100, USAGE) ;
- argv++ ; argc-- ;
- {
- int fd ;
- unsigned int dirlen = str_len(*argv) ;
- char fn[dirlen + 9 + sizeof(S6_SUPERVISE_CTLDIR)] ;
- byte_copy(fn, dirlen, *argv) ;
- fn[dirlen] = '/' ;
- byte_copy(fn + dirlen + 1, sizeof(S6_SUPERVISE_CTLDIR) - 1, S6_SUPERVISE_CTLDIR) ;
- byte_copy(fn + dirlen + sizeof(S6_SUPERVISE_CTLDIR), 9, "/control") ;
- fd = open_write(fn) ;
- if (fd < 0)
- {
- if ((errno == ENXIO) || (errno == ENOENT)) return 1 ;
- else strerr_diefu2sys(111, "open_write ", fn) ;
- }
- }
- return 0 ;
+ r = s6_svc_ok(argv[1]) ;
+ if (r < 0) strerr_diefu2sys(111, "check ", argv[1]) ;
+ return !r ;
}