s6

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

commit 3315cae54873f180a26a37a5aaccaae5febec96e
parent 162fcfac5bb4d2cd40f7adc1d2d9ae71d6c86b19
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Mon, 12 Oct 2015 14:04:28 +0000

 Add SIGWINCH support to s6-supervise and s6-svc (-y)

Diffstat:
Mdoc/s6-svc.html | 3++-
Msrc/supervision/s6-supervise.c | 23++++++++++++++---------
Msrc/supervision/s6-svc.c | 3++-
3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/doc/s6-svc.html b/doc/s6-svc.html @@ -28,7 +28,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> ] [ -abqhkti12pcoduxO ] <em>servicedir</em> + s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T <em>timeout</em> ] [ -abqhkti12pcyoduxO ] <em>servicedir</em> </pre> <p> @@ -52,6 +52,7 @@ a command, or 100 if no s6-supervise process is running on <em>servicedir</em>. <li> <tt>-2</tt>&nbsp;: send a SIGUSR2 to the supervised process </li> <li> <tt>-p</tt>&nbsp;: send a SIGSTOP to the supervised process </li> <li> <tt>-c</tt>&nbsp;: send a SIGCONT to the supervised process </li> + <li> <tt>-y</tt>&nbsp;: send a SIGWINCH to the supervised process </li> <li> <tt>-o</tt>&nbsp;: once. Equivalent to "-uO". </li> <li> <tt>-d</tt>&nbsp;: down. If the supervised process is up, send it a SIGTERM and a SIGCONT. Do not restart it. </li> diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c @@ -26,7 +26,7 @@ typedef enum trans_e trans_t, *trans_t_ref ; enum trans_e { V_TIMEOUT, V_CHLD, V_TERM, V_HUP, V_QUIT, - V_a, V_b, V_q, V_h, V_k, V_t, V_i, V_1, V_2, V_f, V_F, V_p, V_c, + V_a, V_b, V_q, V_h, V_k, V_t, V_i, V_1, V_2, V_f, V_F, V_p, V_c, V_y, V_o, V_d, V_u, V_x, V_O, V_X } ; @@ -178,6 +178,11 @@ static void killc (void) announce() ; } +static void killy (void) +{ + kill(status.pid, SIGWINCH) ; +} + static void failcoe (int fd) { register int e = errno ; @@ -440,22 +445,22 @@ static void finish_X (void) finish_x() ; } -static action_t_ref const actions[5][24] = +static action_t_ref const actions[5][25] = { { &downtimeout, &nop, &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, &down_o, &down_d, &down_u, &bail, &down_O, &bail }, { &uptimeout, &up_z, &up_term, &up_x, &up_X, - &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &nop, &nop, &killp, &killc, + &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &nop, &nop, &killp, &killc, &killy, &up_o, &up_d, &up_u, &up_x, &up_o, &up_X }, { &finishtimeout, &finish_z, &finish_x, &finish_x, &finish_X, - &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, &up_o, &down_d, &finish_u, &finish_x, &up_o, &finish_X }, { &uptimeout, &lastup_z, &up_d, &nop, &closethem, - &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &nop, &nop, &killp, &killc, + &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &nop, &nop, &killp, &killc, &killy, &up_o, &up_d, &nop, &nop, &up_o, &closethem }, { &finishtimeout, &bail, &nop, &nop, &closethem, - &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, &closethem } } ; @@ -536,8 +541,8 @@ static inline void handle_control (int fd) else if (!r) break ; else { - register unsigned int pos = byte_chr("abqhkti12fFpcoduxOX", 19, c) ; - if (pos < 19) (*actions[state][V_a + pos])() ; + register unsigned int pos = byte_chr("abqhkti12fFpcyoduxOX", 20, c) ; + if (pos < 20) (*actions[state][V_a + pos])() ; } } } diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c @@ -26,7 +26,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "abqhkti12pcoduxOXT:w:", &l) ; + register int opt = subgetopt_r(argc, argv, "abqhkti12pcoduxOXyT:w:", &l) ; if (opt == -1) break ; switch (opt) { @@ -47,6 +47,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'x' : case 'O' : case 'X' : + case 'y' : { if (datalen >= DATASIZE) strerr_dief1x(100, "too many commands") ; data[datalen++] = opt ;