summaryrefslogtreecommitdiff
path: root/src/libs6rc/s6rc_servicedir_unblock.c
blob: 6fd846cba5ea03f9417b704253011b7503e1742c (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 <errno.h>
#include <unistd.h>
#include <skalibs/bytestr.h>
#include <s6/s6-supervise.h>
#include <s6-rc/s6rc-servicedir.h>

int s6rc_servicedir_unblock (char const *dir, int h)
{
  if (h)
  {
    unsigned int dirlen = str_len(dir) ;
    char fn[dirlen + 6] ;
    byte_copy(fn, dirlen, dir) ;
    byte_copy(fn + dirlen, 6, "/down") ;
    if (unlink(fn) < 0 && errno != ENOENT) return -1 ;
    if (s6_svc_writectl(dir, S6_SUPERVISE_CTLDIR, "u", 1) < 0) return -1 ;
  }
  return 0 ;
}