From 6a0f761c624be0bab8e6dce80842465aff9c3847 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 23 Apr 2026 16:48:04 +0000 Subject: Support flag-timeout-killpg Also add the missing support for flag-newpidns when compiling a db --- src/libs6rc/s6rc_servicedir_internal.c | 1 + src/s6-rc/s6-rc-compile.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/libs6rc/s6rc_servicedir_internal.c b/src/libs6rc/s6rc_servicedir_internal.c index f52d776..419fd88 100644 --- a/src/libs6rc/s6rc_servicedir_internal.c +++ b/src/libs6rc/s6rc_servicedir_internal.c @@ -21,6 +21,7 @@ static s6_servicedir_desc const svdir_file_list[] = { .name = "notification-fd", .type = S6_FILETYPE_UINT, .options = 0 }, { .name = "lock-fd", .type = S6_FILETYPE_UINT, .options = 0 }, { .name = "timeout-kill", .type = S6_FILETYPE_UINT, .options = 0 }, + { .name = "flag-timeout-killpg", .type = S6_FILETYPE_EMPTY, .options = 0 }, { .name = "timeout-finish", .type = S6_FILETYPE_UINT, .options = 0 }, { .name = "max-death-tally", .type = S6_FILETYPE_UINT, .options = 0 }, { .name = "down-signal", .type = S6_FILETYPE_NORMAL, .options = 0 }, diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c index b9b6955..2947c14 100644 --- a/src/s6-rc/s6-rc-compile.c +++ b/src/s6-rc/s6-rc-compile.c @@ -1293,6 +1293,23 @@ static int copy_uint (char const *compiled, char const *srcfn, char const *dstfn return 0 ; } +static int copy_empty (char const *compiled, char const *srcfn, char const *dstfn) +{ + if (access(srcfn, F_OK) == -1) + { + if (errno == ENOENT) return 0 ; + cleanup(compiled) ; + strerr_diefu2sys(111, "access ", srcfn) ; + } + + if (!openwritenclose_unsafe(dstfn, "", 0)) + { + cleanup(compiled) ; + strerr_diefu2sys(111, "create ", dstfn) ; + } + return 1 ; +} + static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db, char const *const *srcdirs) { size_t clen = strlen(compiled) ; @@ -1305,8 +1322,8 @@ static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db, unsigned int fdnotif = 0 ; unsigned int u ; int ispipelined = db->services[i].x.longrun.nproducers || db->services[i].x.longrun.consumer < db->nlong ; - char srcfn[srcdirlen + len + 18] ; - char dstfn[clen + len + 30] ; + char srcfn[srcdirlen + len + 22] ; + char dstfn[clen + len + 34] ; memcpy(dstfn, compiled, clen) ; memcpy(dstfn + clen, "/servicedirs/", 13) ; memcpy(dstfn + clen + 13, db->string + db->services[i].name, len + 1) ; @@ -1390,6 +1407,10 @@ static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db, memcpy(dstfn + clen + 14 + len, "timeout-kill", 13) ; copy_uint(compiled, srcfn, dstfn, &u) ; + memcpy(srcfn + srcdirlen + len + 2, "flag-timeout-killpg", 20) ; + memcpy(dstfn + clen + 14 + len, "flag-timeout-killpg", 20) ; + copy_empty(compiled, srcfn, dstfn) ; + memcpy(srcfn + srcdirlen + len + 2, "timeout-finish", 15) ; memcpy(dstfn + clen + 14 + len, "timeout-finish", 15) ; copy_uint(compiled, srcfn, dstfn, &u) ; @@ -1402,6 +1423,10 @@ static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db, memcpy(dstfn + clen + 14 + len, "down-signal", 12) ; filecopy_unsafe(srcfn, dstfn, 0644) ; + memcpy(srcfn + srcdirlen + len + 2, "flag-newpidns", 14) ; + memcpy(dstfn + clen + 14 + len, "flag-newpidns", 14) ; + copy_empty(compiled, srcfn, dstfn) ; + memcpy(srcfn + srcdirlen + len + 2, "template", 9) ; memcpy(dstfn + clen + 14 + len, "template", 9) ; if (dircopy(compiled, srcfn, dstfn)) -- cgit v1.3.1