diff options
Diffstat (limited to 'src/libs6')
-rw-r--r-- | src/libs6/deps-lib/s6 | 1 | ||||
-rw-r--r-- | src/libs6/s6_instance_chdirservice.c | 26 | ||||
-rw-r--r-- | src/libs6/s6_supervise_link_names.c | 3 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6 index 2fa977c..732e071 100644 --- a/src/libs6/deps-lib/s6 +++ b/src/libs6/deps-lib/s6 @@ -31,6 +31,7 @@ s6_dtally_pack.o s6_dtally_unpack.o s6_dtally_read.o s6_dtally_write.o +s6_instance_chdirservice.o s6_servicedir_file_list.o s6_svc_ok.o s6_svc_write.o diff --git a/src/libs6/s6_instance_chdirservice.c b/src/libs6/s6_instance_chdirservice.c new file mode 100644 index 0000000..356ee20 --- /dev/null +++ b/src/libs6/s6_instance_chdirservice.c @@ -0,0 +1,26 @@ +/* ISC license. */ + +#include <string.h> +#include <unistd.h> + +#include <skalibs/strerr.h> +#include <skalibs/djbunix.h> + +#include <s6/supervise.h> + +void s6_instance_chdirservice (char const *s) +{ + int fd, r ; + size_t len = strlen(s) ; + char fn[len + 10] ; + if (!*s) strerr_dief1x(100, "invalid service path") ; + memcpy(fn, s, len) ; + memcpy(fn + len, "/instance", 10) ; + if (chdir(fn) == -1) strerr_diefu2sys(111, "chdir to ", fn) ; + fd = open_read(S6_SVSCAN_CTLDIR "/lock") ; + if (fd < 0) strerr_diefu3sys(111, "open ", fn, "/" S6_SVSCAN_CTLDIR "/lock") ; + r = fd_islocked(fd) ; + if (r < 0) strerr_diefu3sys(111, "check lock on ", fn, "/" S6_SVSCAN_CTLDIR "/lock") ; + if (!r) strerr_dief2x(1, "instanced service not running on ", s) ; + fd_close(fd) ; +} diff --git a/src/libs6/s6_supervise_link_names.c b/src/libs6/s6_supervise_link_names.c index 7712e7e..de8e5c5 100644 --- a/src/libs6/s6_supervise_link_names.c +++ b/src/libs6/s6_supervise_link_names.c @@ -11,7 +11,6 @@ #include <skalibs/tai.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> -#include <skalibs/lolstdio.h> #include <s6/ftrigr.h> #include <s6/ftrigw.h> @@ -56,10 +55,8 @@ int s6_supervise_link_names (char const *scdir, char const *const *servicedirs, memset(locked, 0, bitarray_div8(n)) ; memset(logged, 0, bitarray_div8(n)) ; - LOLDEBUG("s6_supervise_link_names: scdir = %s n = %zu options = %u", scdir, n, options) ; for (size_t i = 0 ; i < n ; i++) { - LOLDEBUG("i = %zu dir = %s name = %s", i, servicedirs[i], names[i]) ; struct stat st ; size_t len = strlen(servicedirs[i]) ; size_t nlen = strlen(names[i]) ; |