s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 6d1c11fdbb384e7606ea7fd69ee2044cf448b2ae
parent bbcb30749d3b6dc5e97a7b545999fab13b554dc4
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Tue, 31 Aug 2021 23:33:28 +0000

 Remove race conditions in early services with this ONE SIMPLE TRICK

Signed-off-by: Laurent Bercot <ska@appnovation.com>

Diffstat:
Mpackage/deps.mak | 2+-
Msrc/supervision/s6_svlisten_loop.c | 6++++++
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/package/deps.mak b/package/deps.mak @@ -138,7 +138,7 @@ src/supervision/s6-svscanctl.o src/supervision/s6-svscanctl.lo: src/supervision/ src/supervision/s6-svstat.o src/supervision/s6-svstat.lo: src/supervision/s6-svstat.c src/include/s6/supervise.h src/supervision/s6-svunlink.o src/supervision/s6-svunlink.lo: src/supervision/s6-svunlink.c src/include/s6/supervise.h src/supervision/s6-svwait.o src/supervision/s6-svwait.lo: src/supervision/s6-svwait.c src/supervision/s6-svlisten.h -src/supervision/s6_svlisten_loop.o src/supervision/s6_svlisten_loop.lo: src/supervision/s6_svlisten_loop.c src/supervision/s6-svlisten.h src/include/s6/ftrigr.h src/include/s6/supervise.h +src/supervision/s6_svlisten_loop.o src/supervision/s6_svlisten_loop.lo: src/supervision/s6_svlisten_loop.c src/supervision/s6-svlisten.h src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/supervise.h src/supervision/s6_svlisten_signal_handler.o src/supervision/s6_svlisten_signal_handler.lo: src/supervision/s6_svlisten_signal_handler.c src/supervision/s6-svlisten.h src/usertree/s6-usertree-maker.o src/usertree/s6-usertree-maker.lo: src/usertree/s6-usertree-maker.c src/include/s6/config.h diff --git a/src/supervision/s6_svlisten_loop.c b/src/supervision/s6_svlisten_loop.c @@ -1,18 +1,23 @@ /* ISC license. */ #include <string.h> +#include <unistd.h> + #include <skalibs/bytestr.h> #include <skalibs/bitarray.h> #include <skalibs/strerr2.h> #include <skalibs/iopause.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> + +#include <s6/ftrigw.h> #include <s6/ftrigr.h> #include <s6/supervise.h> #include "s6-svlisten.h" void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, uint16_t *ids, unsigned char *upstate, unsigned char *readystate, tain const *deadline) { + gid_t gid = getegid() ; unsigned int i = 0 ; foo->n = (unsigned int)argc ; foo->ids = ids ; @@ -27,6 +32,7 @@ void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, ui memcpy(s, argv[i], len) ; s[len] = '/' ; memcpy(s + len + 1, S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR)) ; + ftrigw_fifodir_make(s, gid, 0) ; foo->ids[i] = ftrigr_subscribe_g(&foo->a, s, "[DuUdOx]", FTRIGR_REPEAT, deadline) ; if (!foo->ids[i]) strerr_diefu2sys(111, "subscribe to events for ", argv[i]) ; if (!s6_svstatus_read(argv[i], &status)) strerr_diefu1sys(111, "s6_svstatus_read") ;