diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-08-25 23:14:00 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-08-25 23:14:00 +0000 |
commit | 4fb4eaecb937e3eddd8804c85ce20c80cc753480 (patch) | |
tree | a0f530151558a3c721f0aaf9b0e4e28f183de8c0 /src/libs6rc/s6rc_servicedir_unblock.c | |
parent | fc91cc6cd1384a315a1f33bc83e6d6e9926fc791 (diff) | |
download | s6-rc-4fb4eaecb937e3eddd8804c85ce20c80cc753480.tar.xz |
Some refactor + add servicedir copy functions in libs6rc
Diffstat (limited to 'src/libs6rc/s6rc_servicedir_unblock.c')
-rw-r--r-- | src/libs6rc/s6rc_servicedir_unblock.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libs6rc/s6rc_servicedir_unblock.c b/src/libs6rc/s6rc_servicedir_unblock.c new file mode 100644 index 0000000..6fd846c --- /dev/null +++ b/src/libs6rc/s6rc_servicedir_unblock.c @@ -0,0 +1,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 ; +} |