diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-05-25 15:59:58 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-05-25 15:59:58 +0000 |
commit | 3457a5ce01d7df3bc4cdc6259736ca210b4d4765 (patch) | |
tree | 48f91fceb2a2796c215dff98b20433a7de7e8cb1 /src | |
parent | c02e7ac089342801f7f0d3e6f6ebb3eee56959d1 (diff) | |
download | s6-3457a5ce01d7df3bc4cdc6259736ca210b4d4765.tar.xz |
Add s6-svc -s; prepare for 2.11.4.0
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/supervision/s6-svc.c | 32 |
1 files changed, 30 insertions, 2 deletions
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 <skalibs/nonposix.h> + #include <string.h> #include <unistd.h> #include <errno.h> +#include <signal.h> #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> +#include <skalibs/nsig.h> +#include <skalibs/sig.h> #include <skalibs/djbunix.h> #include <skalibs/exec.h> #include <s6/config.h> #include <s6/supervise.h> -#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' : |