summaryrefslogtreecommitdiff
path: root/src/libs6/s6_supervise_unlink.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-08-28 17:18:08 +0000
committerLaurent Bercot <ska@appnovation.com>2021-08-28 17:18:08 +0000
commitfa7f29ff4b5aef142143e9c1d887d73788b703e4 (patch)
tree0ec096b01f94af5a376e37d8720c35f936c449bb /src/libs6/s6_supervise_unlink.c
parent8f00f3a276b4fde40bcd0ddaa4dc89d2b5791d89 (diff)
downloads6-fa7f29ff4b5aef142143e9c1d887d73788b703e4.tar.xz
Add s6-svdir-link and s6-svdir-unlink
Not tested yet; not documented yet; to come soon. Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libs6/s6_supervise_unlink.c')
-rw-r--r--src/libs6/s6_supervise_unlink.c21
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 ;
}