summaryrefslogtreecommitdiff
path: root/src/libs6/s6_svc_writectl.c
blob: 2e308b9797e9c12ba0d5edc6146da7dd2c3efc0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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) ;
}