diff options
Diffstat (limited to 'src/libs6/s6_supervise_unlink.c')
-rw-r--r-- | src/libs6/s6_supervise_unlink.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/libs6/s6_supervise_unlink.c b/src/libs6/s6_supervise_unlink.c index 2e5a9ec..cc263e4 100644 --- a/src/libs6/s6_supervise_unlink.c +++ b/src/libs6/s6_supervise_unlink.c @@ -3,7 +3,7 @@ #include <errno.h> #include <string.h> #include <unistd.h> -#include <limits.h> +#include <sys/stat.h> #include <skalibs/posixplz.h> #include <skalibs/allreadwrite.h> @@ -11,19 +11,13 @@ #include <s6/s6-supervise.h> -#ifdef PATH_MAX -# define S6_PATH_MAX PATH_MAX -#else -# define S6_PATH_MAX 4096 -#endif - void s6_supervise_unlink (char const *scdir, char const *name, uint32_t options) { int e = errno ; - int fd = -1 ; + int fd = -1, fdlog = -1 ; size_t scdirlen = strlen(scdir) ; size_t namelen = strlen(name) ; - char fn[scdirlen + namelen + sizeof(S6_SUPERVISE_CTLDIR) + 10] ; + char fn[scdirlen + namelen + sizeof(S6_SUPERVISE_CTLDIR) + 14] ; memcpy(fn, scdir, scdirlen) ; fn[scdirlen] = '/' ; memcpy(fn + scdirlen + 1, name, namelen) ; @@ -37,7 +31,11 @@ void s6_supervise_unlink (char const *scdir, char const *name, uint32_t options) memcpy(fn + scdirlen + 1 + namelen, "/" S6_SUPERVISE_CTLDIR, sizeof(S6_SUPERVISE_CTLDIR)) ; memcpy(fn + scdirlen + 1 + namelen + sizeof(S6_SUPERVISE_CTLDIR), "/control", 9) ; fd = open_write(fn) ; + memcpy(fn + scdirlen + 1 + namelen, "/log/" S6_SUPERVISE_CTLDIR, 4 + sizeof(S6_SUPERVISE_CTLDIR)) ; + memcpy(fn + scdirlen + 5 + namelen + sizeof(S6_SUPERVISE_CTLDIR), "/control", 9) ; + fdlog = open_write(fn) ; } + fn[scdirlen + 1 + namelen] = 0 ; unlink_void(fn) ; if (fd >= 0) @@ -45,5 +43,10 @@ void s6_supervise_unlink (char const *scdir, char const *name, uint32_t options) fd_write(fd, "xd", 1 + !!(options & 2)) ; fd_close(fd) ; } + if (fdlog >= 0) + { + fd_write(fdlog, "xo", 1 + !!(options & 2)) ; + fd_close(fdlog) ; + } errno = e ; } |