From 923d36dfe83f6f309da7c17fd70e306cd985182c Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 9 Jun 2026 04:44:18 +0000 Subject: Add s6-svc -l and reload-signal --- NEWS | 3 +++ doc/s6-svc.html | 9 ++++++++- doc/servicedir.html | 6 ++++++ doc/upgrade.html | 3 +++ src/libs6/s6_servicedir_file_list.c | 1 + src/supervision/s6-supervise.c | 32 +++++++++++++++++++++++--------- src/supervision/s6-svc.c | 5 +++-- 7 files changed, 47 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 89b9bd0..ad24466 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ In 2.15.1.0 - Bugfixes. - New command: s6-svscanboot, for a self-logging s6-svscan that is not pid 1. + - New service directory file: reload-signal + - New s6-svc control: s6-svc -l, to send the signal defined +in reload-signal, or a SIGHUP by default. In 2.15.0.0 diff --git a/doc/s6-svc.html b/doc/s6-svc.html index a8a5192..5bdbcb1 100644 --- a/doc/s6-svc.html +++ b/doc/s6-svc.html @@ -29,7 +29,7 @@ knowing their PIDs, and without using horrible hacks such as .pid files.

Interface

-     s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -s signal | -abqhkti12pcyrPCK ] [ -oduDUxO ] servicedirs...
+     s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -s signal | -abqhkti12pcyrlPCK ] [ -oduDUxO ] servicedirs...
 

@@ -100,6 +100,13 @@ signal to kill it and letting s6-supervise start it again. By default, the signal is a SIGTERM; this can be configured via the ./down-signal file in the service directory. +

  • -l : If the service is up, reload it, by sending it a +signal that should make it reload its configuration. (Not all services support +this feature, in which case -l will be equivalent to -r.) +By default, the signal is a SIGHUP; this can be configured +via the ./reload-signal file in the service +directory.
  • +
  • -T timeout : if the -wstate option has been given, -T specifies a timeout (in milliseconds) after which s6-svc will exit 1 with an error message if diff --git a/doc/servicedir.html b/doc/servicedir.html index ced24d6..6824559 100644 --- a/doc/servicedir.html +++ b/doc/servicedir.html @@ -214,6 +214,12 @@ newline. This signal will be used to kill the supervised process when a s6-svc -d or s6-svc -r command is used. If the file does not exist, SIGTERM will be used by default.
  • +
  • An optional regular file named reload-signal. If such a file +exists, it must only contain the name or number of a signal, followed by a +newline. This signal will be sent to the supervised process when a +s6-svc -l command is used. If the file does not exist, +SIGHUP will be used by default.
  • +
  • An optional regular file named flag-newpidns. If such a file exists:

    in 2.15.0.0

    diff --git a/src/libs6/s6_servicedir_file_list.c b/src/libs6/s6_servicedir_file_list.c index bbbb68a..2483b40 100644 --- a/src/libs6/s6_servicedir_file_list.c +++ b/src/libs6/s6_servicedir_file_list.c @@ -13,6 +13,7 @@ static s6_servicedir_desc const s6_servicedir_file_list_[] = { .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 }, + { .name = "reload-signal", .type = S6_FILETYPE_NORMAL, .options = 0 }, { .name = "flag-newpidns", .type = S6_FILETYPE_EMPTY, .options = 0 }, { .name = "template", .type = S6_FILETYPE_DIR, .options = 0 }, { .name = "data", .type = S6_FILETYPE_DIR, .options = 0 }, diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c index d9c47c1..6c8391e 100644 --- a/src/supervision/s6-supervise.c +++ b/src/supervision/s6-supervise.c @@ -43,7 +43,7 @@ typedef enum trans_e trans_t, *trans_t_ref ; enum trans_e { V_TIMEOUT, V_CHLD, V_TERM, V_HUP, V_QUIT, V_INT, - V_a, V_b, V_q, V_h, V_k, V_t, V_i, V_1, V_2, V_p, V_c, V_y, V_r, V_P, V_C, V_K, + V_a, V_b, V_q, V_h, V_k, V_t, V_i, V_1, V_2, V_p, V_c, V_y, V_r, V_l, V_P, V_C, V_K, V_o, V_d, V_u, V_D, V_U, V_x, V_O, V_Q } ; @@ -131,7 +131,16 @@ static inline int read_downsig (void) int sig = SIGTERM ; char buf[16] ; if (read_file("down-signal", buf, 15) && !sig0_scan(buf, &sig)) - strerr_warnw1x("invalid down-signal") ; + strerr_warnw("invalid ", "down-signal") ; + return sig ; +} + +static inline int read_reloadsig (void) +{ + int sig = SIGHUP ; + char buf[16] ; + if (read_file("reload-signal", buf, 15) && !sig0_scan(buf, &sig)) + strerr_warnw("invalid ", "reload-signal") ; return sig ; } @@ -264,6 +273,11 @@ static void killr (void) kill(status.pid, read_downsig()) ; } +static void killl (void) +{ + kill(status.pid, read_reloadsig()) ; +} + static void killP (void) { killpg(status.pid, SIGSTOP) ; @@ -602,22 +616,22 @@ static void lastfinish_z (void) bail() ; } -static action_t_ref const actions[5][30] = +static action_t_ref const actions[5][31] = { { &downtimeout, &nop, &bail, &bail, &bail, &bail, - &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, + &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &down_o, &wantdown, &down_u, &wantDOWN, &down_U, &bail, &wantdown, &wantDOWN }, { &uptimeout, &up_z, &up_term, &up_x, &bail, &sigint, - &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &killp, &killc, &killy, &killr, &killP, &killC, &killK, + &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &killp, &killc, &killy, &killr, &killl, &killP, &killC, &killK, &wantdown, &up_d, &wantup, &up_D, &wantUP, &up_x, &wantdown, &wantDOWN }, { &finishtimeout, &finish_z, &finish_x, &finish_x, &bail, &sigint, - &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, + &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &wantdown, &wantdown, &wantup, &wantDOWN, &wantUP, &finish_x, &wantdown, &wantDOWN }, { &uptimeout, &lastup_z, &up_d, &closethem, &bail, &sigint, - &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &killp, &killc, &killy, &killr, &killP, &killC, &killK, + &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &killp, &killc, &killy, &killr, &killl, &killP, &killC, &killK, &wantdown, &up_d, &wantup, &up_D, &wantUP, &closethem, &wantdown, &wantDOWN }, { &finishtimeout, &lastfinish_z, &nop, &closethem, &bail, &sigint, - &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, + &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &wantdown, &wantdown, &wantup, &wantDOWN, &wantUP, &closethem, &wantdown, &wantDOWN } } ; @@ -702,7 +716,7 @@ static inline void handle_control (int fd) else if (!r) break ; else { - size_t pos = byte_chr("abqhkti12pcyrPCKoduDUxOQ", 24, c) ; + size_t pos = byte_chr("abqhkti12pcyrlPCKoduDUxOQ", 25, c) ; if (pos < 24) (*actions[state][V_a + pos])() ; } } diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c index c13b73b..0ddc760 100644 --- a/src/supervision/s6-svc.c +++ b/src/supervision/s6-svc.c @@ -18,7 +18,7 @@ #include #include -#define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -s signal | -abqhkti12pcyrPCK ] [ -oduDUxOQ ] servicedirs..." +#define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -s signal | -abqhkti12pcyrlPCK ] [ -oduDUxOQ ] servicedirs..." #define dieusage() strerr_dieusage(100, USAGE) #define DATASIZE 63 @@ -50,7 +50,7 @@ int main (int argc, char const *const *argv) subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "s:abqhkti12pcyrPCKoduDUxOQT:w:", &l) ; + int opt = subgetopt_r(argc, argv, "s:abqhkti12pcyrlPCKoduDUxOQT:w:", &l) ; if (opt == -1) break ; switch (opt) { @@ -74,6 +74,7 @@ int main (int argc, char const *const *argv) case 'c' : case 'y' : case 'r' : + case 'l' : case 'P' : case 'C' : case 'K' : -- cgit v1.3.1