From 3457a5ce01d7df3bc4cdc6259736ca210b4d4765 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 25 May 2023 15:59:58 +0000 Subject: Add s6-svc -s; prepare for 2.11.4.0 Signed-off-by: Laurent Bercot --- src/supervision/s6-svc.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/supervision') diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c index 1586056..acf8e06 100644 --- a/src/supervision/s6-svc.c +++ b/src/supervision/s6-svc.c @@ -1,25 +1,46 @@ /* ISC license. */ +#include + #include #include #include +#include #include #include #include +#include +#include #include #include #include #include -#define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -abqhkti12pcyroduDUxOQ ] servicedir" +#define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -s signal | -abqhkti12pcy ] [ -roduDUxOQ ] servicedir" #define dieusage() strerr_dieusage(100, USAGE) #define DATASIZE 63 int main (int argc, char const *const *argv) { + static char const cmdsig[NSIG] = + { + 0, + [SIGALRM] = 'a', + [SIGABRT] = 'b', + [SIGQUIT] = 'q', + [SIGHUP] = 'h', + [SIGKILL] = 'k', + [SIGTERM] = 't', + [SIGINT] = 'i', + [SIGUSR1] = '1', + [SIGUSR2] = '2', + [SIGSTOP] = 'p', + [SIGCONT] = 'c', + [SIGWINCH] = 'y' + } ; size_t len ; unsigned int datalen = 1 ; unsigned int timeout = 0 ; @@ -30,10 +51,17 @@ int main (int argc, char const *const *argv) subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "abqhkti12pcyroduDUxOQT:w:", &l) ; + int opt = subgetopt_r(argc, argv, "s:abqhkti12pcyroduDUxOQT:w:", &l) ; if (opt == -1) break ; switch (opt) { + case 's' : + { + int sig ; + if (!sig0_scan(l.arg, &sig)) strerr_dief2x(100, "invalid signal: ", l.arg) ; + if (!cmdsig[sig]) strerr_dief2x(100, l.arg, " is not in the list of user-available signals") ; + opt = cmdsig[sig] ; + } case 'a' : case 'b' : case 'q' : -- cgit 1.4.1