summaryrefslogtreecommitdiff
path: root/src/libs6rc/s6rc_servicedir_unsupervise.c
blob: 7fd20d768a382b0fe8f2b9703dbee65ed2ab1a08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ISC license. */

#include <string.h>

#include <s6/supervise.h>

#include <s6-rc/s6rc-servicedir.h>

void s6rc_servicedir_unsupervise (char const *live, char const *prefix, char const *name, int keepsupervisor)
{
  size_t livelen = strlen(live) ;
  size_t prefixlen = strlen(prefix) ;
  size_t namelen = strlen(name) ;
  char scdir[livelen + 9] ;
  char fn[prefixlen + namelen + 1] ;
  memcpy(scdir, live, livelen) ;
  memcpy(scdir + livelen, "/scandir", 9) ;
  memcpy(fn, prefix, prefixlen) ;
  memcpy(fn + prefixlen, name, namelen + 1) ;
  s6_supervise_unlink(scdir, fn, keepsupervisor ? 0 : 3) ;
}