summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-08-31 23:33:28 +0000
committerLaurent Bercot <ska@appnovation.com>2021-08-31 23:33:28 +0000
commit6d1c11fdbb384e7606ea7fd69ee2044cf448b2ae (patch)
tree39e8cdc7eef1b886ac58941df6ff6694e1c92801
parentbbcb30749d3b6dc5e97a7b545999fab13b554dc4 (diff)
downloads6-6d1c11fdbb384e7606ea7fd69ee2044cf448b2ae.tar.xz
Remove race conditions in early services with this ONE SIMPLE TRICK
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--package/deps.mak2
-rw-r--r--src/supervision/s6_svlisten_loop.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/package/deps.mak b/package/deps.mak
index 37ab05b..28f95c8 100644
--- 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
index c97427f..3a89a9c 100644
--- 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") ;