summaryrefslogtreecommitdiff
path: root/src/libs6/s6_svc_writectl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs6/s6_svc_writectl.c')
-rw-r--r--src/libs6/s6_svc_writectl.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libs6/s6_svc_writectl.c b/src/libs6/s6_svc_writectl.c
new file mode 100644
index 0000000..2e308b9
--- /dev/null
+++ b/src/libs6/s6_svc_writectl.c
@@ -0,0 +1,16 @@
+/* ISC license. */
+
+#include <skalibs/bytestr.h>
+#include <s6/s6-supervise.h>
+
+int s6_svc_writectl (char const *service, char const *subdir, char const *s, unsigned int len)
+{
+ unsigned int svlen = str_len(service) ;
+ unsigned int sublen = str_len(subdir) ;
+ char fn[svlen + sublen + 10] ;
+ byte_copy(fn, svlen, service) ;
+ fn[svlen] = '/' ;
+ byte_copy(fn + svlen + 1, sublen, subdir) ;
+ byte_copy(fn + svlen + 1 + sublen, 9, "/control") ;
+ return s6_svc_write(fn, s, len) ;
+}