From 3315cae54873f180a26a37a5aaccaae5febec96e Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 12 Oct 2015 14:04:28 +0000 Subject: Add SIGWINCH support to s6-supervise and s6-svc (-y) --- doc/s6-svc.html | 3 ++- src/supervision/s6-supervise.c | 23 ++++++++++++++--------- src/supervision/s6-svc.c | 3 ++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/doc/s6-svc.html b/doc/s6-svc.html index 7c3b2bd..62fd1be 100644 --- 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.

Interface

-     s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -abqhkti12pcoduxO ] servicedir
+     s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -abqhkti12pcyoduxO ] servicedir
 

@@ -52,6 +52,7 @@ a command, or 100 if no s6-supervise process is running on servicedir.

  • -2 : send a SIGUSR2 to the supervised process
  • -p : send a SIGSTOP to the supervised process
  • -c : send a SIGCONT to the supervised process
  • +
  • -y : send a SIGWINCH to the supervised process
  • -o : once. Equivalent to "-uO".
  • -d : down. If the supervised process is up, send it a SIGTERM and a SIGCONT. Do not restart it.
  • diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c index 4a09eaf..f682040 100644 --- 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 index 467c174..cc92618 100644 --- 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 ; -- cgit v1.3.1