diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-06-09 04:44:18 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-06-09 04:44:18 +0000 |
| commit | 923d36dfe83f6f309da7c17fd70e306cd985182c (patch) | |
| tree | c2951bd1f01418982514d6434be6326b9c9187ca | |
| parent | 06d97dd40108bc685a4fab846cc156827534d15b (diff) | |
| download | s6-923d36dfe83f6f309da7c17fd70e306cd985182c.tar.gz | |
Add s6-svc -l and reload-signal
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | doc/s6-svc.html | 9 | ||||
| -rw-r--r-- | doc/servicedir.html | 6 | ||||
| -rw-r--r-- | doc/upgrade.html | 3 | ||||
| -rw-r--r-- | src/libs6/s6_servicedir_file_list.c | 1 | ||||
| -rw-r--r-- | src/supervision/s6-supervise.c | 32 | ||||
| -rw-r--r-- | src/supervision/s6-svc.c | 5 |
7 files changed, 47 insertions, 12 deletions
@@ -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. <h2> Interface </h2> <pre> - s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T <em>timeout</em> ] [ -s <em>signal</em> | -abqhkti12pcyrPCK ] [ -oduDUxO ] <em>servicedirs...</em> + s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T <em>timeout</em> ] [ -s <em>signal</em> | -abqhkti12pcyrlPCK ] [ -oduDUxO ] <em>servicedirs...</em> </pre> <p> @@ -100,6 +100,13 @@ signal to kill it and letting <a href="s6-supervise.html">s6-supervise</a> start it again. By default, the signal is a SIGTERM; this can be configured via the <tt>./down-signal</tt> file in the <a href="servicedir.html">service directory</a>. </li> + <li> <tt>-l</tt> : 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 <tt>-l</tt> will be equivalent to <tt>-r</tt>.) +By default, the signal is a SIGHUP; this can be configured +via the <tt>./reload-signal</tt> file in the <a href="servicedir.html">service +directory</a>. </li> + <li> <tt>-T <em>timeout</em></tt> : if the <tt>-w<em>state</em></tt> option has been given, <tt>-T</tt> 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 <a href="s6-svc.html">s6-svc -d</a> or <a href="s6-svc.html">s6-svc -r</a> command is used. If the file does not exist, SIGTERM will be used by default. </li> + <li style="margin-bottom:1em"> An optional regular file named <tt>reload-signal</tt>. 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 +<a href="s6-svc.html">s6-svc -l</a> command is used. If the file does not exist, +SIGHUP will be used by default. </li> + <li style="margin-bottom:1em"> An optional regular file named <tt>flag-newpidns</tt>. If such a file exists: <ul> diff --git a/doc/upgrade.html b/doc/upgrade.html index 43bd3f4..cd2d648 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -27,6 +27,9 @@ dependency bumped to 2.15.0.1. </li> <li> <a href="//skarnet.org/software/execline/">execline</a> recommended dependency bumped to 2.9.9.2. </li> <li> New <a href="s6-svscanboot.html">s6-svscanboot</a> binary. </li> + <li> New -l option to <a href="s6-svc.html">s6-svc</a>. </li> + <li> New optional <tt>reload-signal</tt> file in a +<a href="servicedir.html">service directory</a>. </li> </ul> <h2> in 2.15.0.0 </h2> 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 <s6/config.h> #include <s6/supervise.h> -#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' : |
