summaryrefslogtreecommitdiff
path: root/src/libs6/s6_dtally_write.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-03-20 14:52:26 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-03-20 14:52:26 +0000
commit26c5fee82736e56cff3d114ff9d6e3969d1ce061 (patch)
treea43283438dc8d22b339cda86b0d80c58ef86bf4d /src/libs6/s6_dtally_write.c
parent1747a0f5142f0c36a61b37786368f05bcb3060f3 (diff)
downloads6-26c5fee82736e56cff3d114ff9d6e3969d1ce061.tar.xz
Add death tally support to s6-supervise, throttling support to s6_svstatus_t
Diffstat (limited to 'src/libs6/s6_dtally_write.c')
-rw-r--r--src/libs6/s6_dtally_write.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libs6/s6_dtally_write.c b/src/libs6/s6_dtally_write.c
new file mode 100644
index 0000000..785376a
--- /dev/null
+++ b/src/libs6/s6_dtally_write.c
@@ -0,0 +1,16 @@
+/* ISC license. */
+
+#include <string.h>
+#include <skalibs/djbunix.h>
+#include <s6/s6-supervise.h>
+
+int s6_dtally_write (char const *sv, s6_dtally_t const *tab, size_t n)
+{
+ size_t len = strlen(sv) ;
+ char fn[len + sizeof(S6_DTALLY_FILENAME) + 1] ;
+ char tmp[n ? S6_DTALLY_PACK * n : 1] ;
+ memcpy(fn, sv, len) ;
+ memcpy(fn + len, "/" S6_DTALLY_FILENAME, sizeof(S6_DTALLY_FILENAME) + 1) ;
+ for (size_t i = 0 ; i < n ; i++) s6_dtally_pack(tmp + i * S6_DTALLY_PACK, tab + i) ;
+ return openwritenclose_suffix(fn, tmp, n * S6_DTALLY_PACK, ".new") ;
+}