1 /* ISC license. */
2
3 #include <string.h>
4 #include <skalibs/djbunix.h>
5 #include <s6/s6-supervise.h>
6
s6_svstatus_write(char const * dir,s6_svstatus_t const * status)7 int s6_svstatus_write (char const *dir, s6_svstatus_t const *status)
8 {
9 size_t n = strlen(dir) ;
10 char pack[S6_SVSTATUS_SIZE] ;
11 char tmp[n + 1 + sizeof(S6_SVSTATUS_FILENAME)] ;
12 memcpy(tmp, dir, n) ;
13 memcpy(tmp + n, "/" S6_SVSTATUS_FILENAME, 1 + sizeof(S6_SVSTATUS_FILENAME)) ;
14 s6_svstatus_pack(pack, status) ;
15 return openwritenclose_suffix(tmp, pack, S6_SVSTATUS_SIZE, ".new") ;
16 }
17