summaryrefslogtreecommitdiff
path: root/src/serverlib/s6rc_servicedir_unblock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/serverlib/s6rc_servicedir_unblock.c')
-rw-r--r--src/serverlib/s6rc_servicedir_unblock.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/serverlib/s6rc_servicedir_unblock.c b/src/serverlib/s6rc_servicedir_unblock.c
new file mode 100644
index 0000000..2a10bfd
--- /dev/null
+++ b/src/serverlib/s6rc_servicedir_unblock.c
@@ -0,0 +1,21 @@
+/* ISC license. */
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <s6/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 ;
+ }
+ return 0 ;
+}