summaryrefslogtreecommitdiff
path: root/src/libs6/s6_svc_writectl.c
blob: b4d8e15eed0101bc8d7521e27737b92e577bb2da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* ISC license. */

#include <string.h>
#include <s6/s6-supervise.h>

int s6_svc_writectl (char const *service, char const *subdir, char const *s, size_t len)
{
  size_t svlen = strlen(service) ;
  size_t sublen = strlen(subdir) ;
  char fn[svlen + sublen + 10] ;
  memcpy(fn, service, svlen) ;
  fn[svlen] = '/' ;
  memcpy(fn + svlen + 1, subdir, sublen) ;
  memcpy(fn + svlen + 1 + sublen, "/control", 9) ;
  return s6_svc_write(fn, s, len) ;
}