aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/s6-frontend/deps-exe/s6-frontend7
-rw-r--r--src/s6-frontend/help.c10
-rw-r--r--src/s6-frontend/live.c39
-rw-r--r--src/s6-frontend/live_help.c18
-rw-r--r--src/s6-frontend/live_startstop.c (renamed from src/s6-frontend/service_startstop.c)43
-rw-r--r--src/s6-frontend/live_status.c18
-rw-r--r--src/s6-frontend/process.c44
-rw-r--r--src/s6-frontend/process_help.c6
-rw-r--r--src/s6-frontend/process_kill.c42
-rw-r--r--src/s6-frontend/process_restart.c39
-rw-r--r--src/s6-frontend/process_startstop.c60
-rw-r--r--src/s6-frontend/process_status.c21
-rw-r--r--src/s6-frontend/s6-frontend-internal.h55
-rw-r--r--src/s6-frontend/s6-frontend.c4
-rw-r--r--src/s6-frontend/service.c28
-rw-r--r--src/s6-frontend/service_help.c6
-rw-r--r--src/s6-frontend/service_status.c31
17 files changed, 279 insertions, 192 deletions
diff --git a/src/s6-frontend/deps-exe/s6-frontend b/src/s6-frontend/deps-exe/s6-frontend
index 8bb5b58..62ca26a 100644
--- a/src/s6-frontend/deps-exe/s6-frontend
+++ b/src/s6-frontend/deps-exe/s6-frontend
@@ -1,14 +1,17 @@
help.o
+live.o
+live_help.o
+live_startstop.o
+live_status.o
process.o
process_help.o
process_kill.o
process_restart.o
process_startstop.o
process_status.o
+s6-frontend.o
service.o
service_help.o
-service_startstop.o
-service_status.o
libs6f.a.xyzzy
${LIBNSSS}
-ls6rc
diff --git a/src/s6-frontend/help.c b/src/s6-frontend/help.c
index 0e119d1..f9994b2 100644
--- a/src/s6-frontend/help.c
+++ b/src/s6-frontend/help.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <unistd.h>
+
#include <skalibs/buffer.h>
#include <skalibs/strerr.h>
@@ -8,18 +10,18 @@
#define MAIN_HELP_MESSAGE "This is the main help message.\n"
-int version (char const *const *argv)
+void version (char const *const *argv)
{
(void)argv ;
if (!buffer_putsflush(buffer_1, "s6-frontend v" S6_FRONTEND_VERSION "\n"))
strerr_diefu1sys(111, "write to stdout") ;
- return 0 ;
+ _exit(0) ;
}
-int help (char const *const *argv)
+void help (char const *const *argv)
{
(void)argv ;
if (!buffer_putsflush(buffer_1, MAIN_HELP_MESSAGE))
strerr_diefu1sys(111, "write to stdout") ;
- return 0 ;
+ _exit(0) ;
}
diff --git a/src/s6-frontend/live.c b/src/s6-frontend/live.c
new file mode 100644
index 0000000..22e7516
--- /dev/null
+++ b/src/s6-frontend/live.c
@@ -0,0 +1,39 @@
+/* ISC license. */
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <skalibs/uint64.h>
+#include <skalibs/stat.h>
+#include <skalibs/types.h>
+#include <skalibs/posixplz.h>
+#include <skalibs/envexec.h>
+#include <skalibs/djbunix.h>
+
+#include <s6/config.h>
+
+#include "s6-frontend-internal.h"
+
+#define USAGE "s6 live subcommand [ subcommand options ] [ services... ] Type \"s6 live help\" for details."
+#define dieusage() strerr_dieusage(100, USAGE)
+
+void live (char const *const *argv)
+{
+ static struct command_s const commands[] =
+ {
+ { .s = "help", .f = &live_help },
+ { .s = "restart", .f = &live_restart },
+ { .s = "start", .f = &live_start },
+ { .s = "status", .f = &live_status },
+ { .s = "stop", .f = &live_stop },
+ } ;
+ struct command_s *cmd ;
+
+ argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ;
+ if (!*argv) dieusage() ;
+ cmd = BSEARCH(struct command_s, *argv, commands) ;
+ if (!cmd) dieusage() ;
+ (*cmd->f)(++argv) ;
+ _exit(101) ;
+}
diff --git a/src/s6-frontend/live_help.c b/src/s6-frontend/live_help.c
new file mode 100644
index 0000000..ca52623
--- /dev/null
+++ b/src/s6-frontend/live_help.c
@@ -0,0 +1,18 @@
+/* ISC license. */
+
+#include <unistd.h>
+
+#include <skalibs/buffer.h>
+#include <skalibs/strerr.h>
+
+#include "s6-frontend-internal.h"
+
+#define LIVE_HELP_MESSAGE "This is the live help message.\n"
+
+void live_help (char const *const *argv)
+{
+ (void)argv ;
+ if (!buffer_putsflush(buffer_1, LIVE_HELP_MESSAGE))
+ strerr_diefu1sys(111, "write to stdout") ;
+ _exit(0) ;
+}
diff --git a/src/s6-frontend/service_startstop.c b/src/s6-frontend/live_startstop.c
index dee160f..bbe72c9 100644
--- a/src/s6-frontend/service_startstop.c
+++ b/src/s6-frontend/live_startstop.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <sys/wait.h>
+#include <unistd.h>
#include <skalibs/posixplz.h>
#include <skalibs/uint64.h>
@@ -19,9 +20,7 @@
enum golb_e
{
- GOLB_DRYRUN,
- GOLB_WAIT,
- GOLB_N
+ GOLB_DRYRUN = 0x01,
} ;
enum gola_e
@@ -30,20 +29,17 @@ enum gola_e
GOLA_N
} ;
-static gol_bool const rgolb[3] =
+int live_startstop (char const *const *argv, int h)
{
- { .so = 'n', .lo = "dryrun", .clear = 0, .set = 1 << GOLB_DRYRUN },
- { .so = 'W', .lo = "nowait", .clear = 1 << GOLB_WAIT, .set = 0 },
- { .so = 'w', .lo = "wait", .clear = 0, .set = 1 << GOLB_WAIT }
-} ;
-
-static gol_arg const rgola[GOLA_N] =
-{
- { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT }
-} ;
+ static gol_bool const rgolb[] =
+ {
+ { .so = 'n', .lo = "dry-run", .clear = 0, .set = GOLB_DRYRUN },
+ } ;
+ static gol_arg const rgola[] =
+ {
+ { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT },
+ } ;
-static int service_startstop (char const *const *argv, int h)
-{
char const *wgola[GOLA_N] = { 0 } ;
uint64_t wgolb = 0 ;
unsigned int t = 0 ;
@@ -53,10 +49,9 @@ static int service_startstop (char const *const *argv, int h)
uint32_t nlong, nshort, n ;
int livelock, compiledlock ;
size_t livelen = strlen(g->dirs.live) ;
- PROG = h ? "s6 service start" : "s6 service stop" ;
- argv += gol_argv(argv, rgolb, 3, rgola, GOLA_N, &wgolb, wgola) ;
- if (!*argv) strerr_dieusage(100, h ? "s6 service start services..." : "s6 service stop services...") ;
+ argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ;
+ if (!*argv) strerr_dieusage(100, h ? "s6 live start services..." : "s6 live stop services...") ;
if (wgola[GOLA_TIMEOUT])
{
@@ -93,7 +88,7 @@ static int service_startstop (char const *const *argv, int h)
newargv[m++] = fmtt ;
fmtt[uint_fmt(fmtt, t)] = 0 ;
}
- if (wgolb & 1 << GOLB_DRYRUN)
+ if (wgolb & GOLB_DRYRUN)
{
newargv[m++] = "-n" ;
newargv[m++] = "1" ;
@@ -114,16 +109,16 @@ static int service_startstop (char const *const *argv, int h)
unsigned char newstate[n] ;
if (!s6rc_live_state_read(g->dirs.live, newstate, n))
strerr_diefu2sys(111, "read state in ", g->dirs.live) ;
- s6f_report_state_change(n, oldstate, newstate, dbfn, h) ;
+ if (g->verbosity) s6f_report_state_change(n, oldstate, newstate, dbfn, h) ;
return wait_estatus(wstat) ;
}
-int service_start (char const *const *argv)
+void service_start (char const *const *argv)
{
- return service_startstop(argv, 1) ;
+ _exit(live_startstop(argv, 1)) ;
}
-int service_stop (char const *const *argv)
+void service_stop (char const *const *argv)
{
- return service_startstop(argv, 0) ;
+ _exit(live_startstop(argv, 0)) ;
}
diff --git a/src/s6-frontend/live_status.c b/src/s6-frontend/live_status.c
new file mode 100644
index 0000000..67c6782
--- /dev/null
+++ b/src/s6-frontend/live_status.c
@@ -0,0 +1,18 @@
+/* ISC license. */
+
+#include <unistd.h>
+
+#include <skalibs/strerr.h>
+#include <skalibs/gol.h>
+
+#include "s6-frontend-internal.h"
+
+#define USAGE "s6 live status services..."
+#define dieusage() strerr_dieusage(100, USAGE)
+
+void live_status (char const *const *argv)
+{
+ argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ;
+ if (!argv) dieusage() ;
+ _exit(0) ;
+}
diff --git a/src/s6-frontend/process.c b/src/s6-frontend/process.c
index f6b3f12..5e96d13 100644
--- a/src/s6-frontend/process.c
+++ b/src/s6-frontend/process.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#include <skalibs/uint64.h>
#include <skalibs/stat.h>
@@ -17,7 +18,7 @@
#define USAGE "s6 process [ process options ] subcommand [ subcommand options ] services... Type \"s6 process help\" for details."
#define dieusage() strerr_dieusage(100, USAGE)
-static int check_service (char const *name, size_t scandirlen)
+static inline int check_service (char const *name, size_t scandirlen)
{
struct stat st ;
size_t namelen = strlen(name) ;
@@ -75,21 +76,9 @@ void process_send_svc (char const *svcopt, char const *const *argv, unsigned int
xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
}
-
-enum golb_e
-{
- GOLB_WAIT = 0x01,
-} ;
-
-enum gola_e
+void process (char const *const *argv)
{
- GOLA_TIMEOUT,
- GOLA_N
-} ;
-
-int process (char const *const *argv)
-{
- static struct process_command_s const process_commands[] =
+ static struct command_s const process_commands[] =
{
{ .s = "help", .f = &process_help },
{ .s = "kill", .f = &process_kill },
@@ -98,26 +87,11 @@ int process (char const *const *argv)
{ .s = "status", .f = &process_status },
{ .s = "stop", .f = &process_stop },
} ;
- static gol_bool const rgolb[] =
- {
- { .so = 'W', .lo = "nowait", .clear = GOLB_WAIT, .set = 0 },
- { .so = 'w', .lo = "wait", .clear = 0, .set = GOLB_WAIT }
- } ;
- static gol_arg const rgola[] =
- {
- { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT },
- } ;
-
- struct process_command_s *cmd ;
- process_options options = PROCESS_OPTIONS_ZERO ;
- char const *wgola[GOLA_N] = { 0 } ;
-
- argv += GOL_argv(argv, rgolb, rgola, &options.flags, wgola) ;
+ struct command_s *cmd ;
+ argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ;
if (!*argv) dieusage() ;
- if (wgola[GOLA_TIMEOUT] && !uint0_scan(wgola[GOLA_TIMEOUT], &options.timeout))
- strerr_dief1x(100, "timeout must be a numerical argument (milliseconds)") ;
- cmd = BSEARCH(struct process_command_s, *argv, process_commands) ;
+ cmd = BSEARCH(struct command_s, *argv, process_commands) ;
if (!cmd) dieusage() ;
- (*cmd->f)(++argv, &options) ;
- return 0 ;
+ (*cmd->f)(++argv) ;
+ _exit(101) ;
}
diff --git a/src/s6-frontend/process_help.c b/src/s6-frontend/process_help.c
index 295d5c6..7399565 100644
--- a/src/s6-frontend/process_help.c
+++ b/src/s6-frontend/process_help.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <unistd.h>
+
#include <skalibs/buffer.h>
#include <skalibs/strerr.h>
@@ -7,10 +9,10 @@
#define PROCESS_HELP_MESSAGE "This is the process help message.\n"
-void process_help (char const *const *argv, process_options const *options)
+void process_help (char const *const *argv)
{
if (!buffer_putsflush(buffer_1, PROCESS_HELP_MESSAGE))
strerr_diefu1sys(111, "write to stdout") ;
(void)argv ;
- (void)options ;
+ _exit(0) ;
}
diff --git a/src/s6-frontend/process_kill.c b/src/s6-frontend/process_kill.c
index ce16a91..6285e70 100644
--- a/src/s6-frontend/process_kill.c
+++ b/src/s6-frontend/process_kill.c
@@ -17,7 +17,7 @@
#include "s6f.h"
#include "s6-frontend-internal.h"
-#define USAGE "s6 process kill [ --signal=sig ] services..."
+#define USAGE "s6 process kill [ --signal=sig ] [ --timeout=millisecs ] [ --wait | --nowait ] services..."
#define dieusage() strerr_dieusage(100, USAGE)
static void process_kill_hack_kill (int sig, char const *const *argv, unsigned int argc, int dowait, unsigned int timeout) gccattr_noreturn ;
@@ -70,33 +70,49 @@ static void process_kill_hack_kill (int sig, char const *const *argv, unsigned i
xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
}
+enum golb_e
+{
+ GOLB_WAIT = 0x01,
+} ;
enum gola_e
{
GOLA_SIGNAL,
+ GOLA_TIMEOUT,
GOLA_N
} ;
-static gol_arg const rgola[] =
-{
- { .so = 's', .lo = "signal", .i = GOLA_SIGNAL },
-} ;
-
-void process_kill (char const *const *argv, process_options const *options)
+void process_kill (char const *const *argv)
{
+ static gol_bool const rgolb[] =
+ {
+ { .so = 'W', .lo = "nowait", .clear = GOLB_WAIT, .set = 0 },
+ { .so = 'w', .lo = "wait", .clear = 0, .set = GOLB_WAIT },
+ } ;
+ static gol_arg const rgola[] =
+ {
+ { .so = 's', .lo = "signal", .i = GOLA_SIGNAL },
+ { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT },
+ } ;
char const *wgola[GOLA_N] = { 0 } ;
- size_t argc ;
+ uint64_t wgolb = 0 ;
+ unsigned int timeout = 0 ;
int sig = SIGTERM ;
+ unsigned int argc ;
char svcopt[5] = "-!\0\0\0" ;
- PROG = "s6-frontend: process kill" ;
- argv += gol_argv(argv, 0, 0, rgola, GOLA_N, 0, wgola) ;
+ argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ;
if (!argv) dieusage() ;
if (wgola[GOLA_SIGNAL])
{
if (!sig0_scan(wgola[GOLA_SIGNAL], &sig))
strerr_dief1x(100, "--signal= argument must be the name or number of a signal") ;
}
+ if (wgola[GOLA_TIMEOUT])
+ {
+ if (!uint0_scan(wgola[GOLA_TIMEOUT], &timeout))
+ strerr_dief1x(100, "--timeout= argument must be an unsigned integer (in milliseconds)") ;
+ }
argc = env_len(argv) ;
process_check_services(argv, argc) ;
switch (sig)
@@ -114,7 +130,7 @@ void process_kill (char const *const *argv, process_options const *options)
case SIGCONT : svcopt[1] = 'c' ; break ;
case SIGWINCH: svcopt[1] = 'y' ; break ;
}
- if (options->flags & 1) { svcopt[2] = 'w' ; svcopt[3] = 'D' ; }
- if (svcopt[1] != '!') process_send_svc(svcopt, argv, argc, options->timeout) ;
- else process_kill_hack_kill(sig, argv, argc, options->flags & 1, options->timeout) ;
+ if (wgolb & GOLB_WAIT) { svcopt[2] = 'w' ; svcopt[3] = 'D' ; }
+ if (svcopt[1] != '!') process_send_svc(svcopt, argv, argc, timeout) ;
+ else process_kill_hack_kill(sig, argv, argc, !!(wgolb & GOLB_WAIT), timeout) ;
}
diff --git a/src/s6-frontend/process_restart.c b/src/s6-frontend/process_restart.c
index 6b8f935..d23ced2 100644
--- a/src/s6-frontend/process_restart.c
+++ b/src/s6-frontend/process_restart.c
@@ -9,12 +9,43 @@
#include "s6-frontend-internal.h"
-#define USAGE "s6 process restart [ -W|--nowait ] services..."
+#define USAGE "s6 process restart [ -W|--nowait | -w|--wait ] [ -t timeout | --timeout=timeout ] services..."
#define dieusage() strerr_dieusage(100, USAGE)
-void process_restart (char const *const *argv, process_options const *options)
+enum golb_e
{
- size_t argc = env_len(argv) ;
+ GOLB_WAIT = 0x01,
+} ;
+
+enum gola_e
+{
+ GOLA_TIMEOUT,
+ GOLA_N
+} ;
+
+void process_restart (char const *const *argv)
+{
+ static gol_bool const rgolb[] =
+ {
+ { .so = 'W', .lo = "nowait", .clear = GOLB_WAIT, .set = 0 },
+ { .so = 'w', .lo = "wait", .clear = 0, .set = GOLB_WAIT },
+ } ;
+ static gol_arg const rgola[] =
+ {
+ { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT },
+ } ;
+ char const *wgola[GOLA_N] = { 0 } ;
+ uint64_t wgolb = 0 ;
+ unsigned int timeout = 0 ;
+ unsigned int argc ;
+ argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ;
+ if (!argv) dieusage() ;
+ if (wgola[GOLA_TIMEOUT])
+ {
+ if (!uint0_scan(wgola[GOLA_TIMEOUT], &timeout))
+ strerr_dief1x(100, "--timeout= argument must be an unsigned integer (in milliseconds)") ;
+ }
+ argc = env_len(argv) ;
process_check_services(argv, argc) ;
- process_send_svc(options->flags & 1 ? "-rwR" : "-r", argv, argc, options->timeout) ;
+ process_send_svc(wgolb & GOLB_WAIT ? "-rwR" : "-r", argv, argc, timeout) ;
}
diff --git a/src/s6-frontend/process_startstop.c b/src/s6-frontend/process_startstop.c
index a80c579..75bf5a0 100644
--- a/src/s6-frontend/process_startstop.c
+++ b/src/s6-frontend/process_startstop.c
@@ -4,37 +4,61 @@
#include <skalibs/gccattributes.h>
#include <skalibs/uint64.h>
-#include <skalibs/env.h>
-#include <skalibs/strerr.h>
-#include <skalibs/gol.h>
+#include <skalibs/envexec.h>
#include "s6-frontend-internal.h"
-static void process_startstop (char const *const *argv, process_options const *options, int h) gccattr_noreturn ;
-static void process_startstop (char const *const *argv, process_options const *options, int h)
+enum golb_e
{
+ GOLB_PERMANENT = 0x02,
+ GOLB_WAIT = 0x04,
+} ;
+
+enum gola_e
+{
+ GOLA_TIMEOUT,
+ GOLA_N
+} ;
+
+static void process_startstop (char const *const *argv, int h, char const *usage) gccattr_noreturn ;
+static void process_startstop (char const *const *argv, int h, char const *usage)
+{
+ static char const *svcopts[8] = { "-d", "-u", "-D", "-U", "-dwD", "-uwU", "-DwD", "-UwU" } ;
static gol_bool const rgolb[] =
{
- { .so = 'P', .lo = "no-permanent", .clear = 0x01, .set = 0 },
- { .so = 'p', .lo = "permanent", .clear = 0, .set = 0x01 }
+ { .so = 'P', .lo = "no-permanent", .clear = GOLB_PERMANENT, .set = 0 },
+ { .so = 'p', .lo = "permanent", .clear = 0, .set = GOLB_PERMANENT },
+ { .so = 'W', .lo = "nowait", .clear = GOLB_WAIT, .set = 0 },
+ { .so = 'w', .lo = "wait", .clear = 0, .set = GOLB_WAIT },
} ;
- static char const *svcopts[2][2][2] = { { { "-d", "-u" }, { "-D", "-U" } }, { { "-dwD", "-uwU" }, { "-DwD", "-UwU" } } } ;
- size_t argc = env_len(argv) ;
+ static gol_arg const rgola[] =
+ {
+ { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT },
+ } ;
+ char const *wgola[GOLA_N] = { 0 } ;
uint64_t wgolb = 0 ;
- unsigned int golc = gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ;
- argc -= golc ; argv += golc ;
- if (!argc) strerr_dief3x(100, "usage: s6 process ", h ? "start" : "stop", " [ -P | -p ] services...") ;
-
+ unsigned int timeout = 0 ;
+ unsigned int argc ;
+ argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ;
+ if (!*argv) strerr_dieusage(100, usage) ;
+ if (wgola[GOLA_TIMEOUT])
+ {
+ if (!uint0_scan(wgola[GOLA_TIMEOUT], &timeout))
+ strerr_dief1x(100, "--timeout= argument must be an unsigned integer (in milliseconds)") ;
+ }
+ argc = env_len(argv) ;
process_check_services(argv, argc) ;
- process_send_svc(svcopts[options->flags & 1][wgolb & 1][h], argv, argc, options->timeout) ;
+ process_send_svc(svcopts[h|GOLB_PERMANENT|GOLB_WAIT], argv, argc, timeout) ;
}
-void process_start (char const *const *argv, process_options const *options)
+void process_start (char const *const *argv)
{
- process_startstop(argv, options, 1) ;
+ static char const *const usage = "s6 process start [ --permanent ] [ --wait ] [ --timeout=millisecs ] services..." ;
+ process_startstop(argv, 1, usage) ;
}
-void process_stop (char const *const *argv, process_options const *options)
+void process_stop (char const *const *argv)
{
- process_startstop(argv, options, 0) ;
+ static char const *const usage = "s6 process stop [ --permanent ] [ --wait ] [ --timeout=millisecs ] services..." ;
+ process_startstop(argv, 0, usage) ;
}
diff --git a/src/s6-frontend/process_status.c b/src/s6-frontend/process_status.c
index ea76d9f..566713e 100644
--- a/src/s6-frontend/process_status.c
+++ b/src/s6-frontend/process_status.c
@@ -18,7 +18,7 @@
#include "s6-frontend-internal.h"
-#define USAGE "s6 process status [ -l|--with-logs ] services..."
+#define USAGE "s6 process status [ --with-logs ] services..."
#define dieusage() strerr_dieusage(100, USAGE)
static int spawn_and_wait (char const *const *argv)
@@ -40,7 +40,7 @@ static int spawn_and_wait (char const *const *argv)
return !!WIFSIGNALED(wstat) || !!WEXITSTATUS(wstat) ;
}
-static int do_status (char const *dir, int withlog)
+static inline int do_status (char const *dir, int withlog)
{
int e ;
char const *argv[4] = { S6_EXTBINPREFIX "s6-svstat", "--", dir, 0 } ;
@@ -73,19 +73,23 @@ static int do_status (char const *dir, int withlog)
return e ;
}
-
-static gol_bool const rgolb[1] =
+enum golb_e
{
- { .so = 'l', .lo = "with-logs", .clear = 0, .set = 0x01 }
+ GOLB_WITHLOGS = 0x01,
} ;
-void process_status (char const *const *argv, process_options const *options)
+void process_status (char const *const *argv)
{
+ static gol_bool const rgolb[] =
+ {
+ { .so = 'L', .lo = "without-logs", .clear = GOLB_WITHLOGS, .set = 0 },
+ { .so = 'l', .lo = "with-logs", .clear = 0, .set = GOLB_WITHLOGS },
+ } ;
size_t scandirlen = strlen(g->dirs.scan) ;
uint64_t wgolb = 0 ;
int e = 0 ;
- argv += gol_argv(argv, rgolb, 1, 0, 0, &wgolb, 0) ;
+ argv += gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ;
if (!argv) dieusage() ;
process_check_services(argv, env_len(argv)) ;
for (; *argv ; argv++)
@@ -95,8 +99,7 @@ void process_status (char const *const *argv, process_options const *options)
memcpy(path, g->dirs.scan, scandirlen) ;
path[scandirlen] = '/' ;
memcpy(path + scandirlen + 1, *argv, len+1) ;
- if (do_status(path, wgolb & 1)) e = 1 ;
+ if (do_status(path, wgolb & GOLB_WITHLOGS)) e = 1 ;
}
- (void)options ;
_exit(e) ;
}
diff --git a/src/s6-frontend/s6-frontend-internal.h b/src/s6-frontend/s6-frontend-internal.h
index b4bfe98..ef27c86 100644
--- a/src/s6-frontend/s6-frontend-internal.h
+++ b/src/s6-frontend/s6-frontend-internal.h
@@ -21,51 +21,40 @@
/* help */
-extern int help (char const *const *) ;
-extern int version (char const *const *) ;
+extern void help (char const *const *) gccattr_noreturn ;
+extern void version (char const *const *) gccattr_noreturn ;
- /* process */
+ /* live */
-typedef struct process_options_s process_options, *process_options_ref ;
-struct process_options_s
-{
- uint64_t flags ;
- unsigned int timeout ;
-} ;
-#define PROCESS_OPTIONS_ZERO { .flags = 0, .timeout = 0 }
+extern int live_startstop (char const *const *, int h) ;
-typedef void process_command_func (char const *const *, process_options const *) ;
-typedef process_command_func *process_command_func_ref ;
+extern void live (char const *const *) gccattr_noreturn ;
+extern void live_help (char const *const *) gccattr_noreturn ;
+extern void live_restart (char const *const *) gccattr_noreturn ;
+extern void live_start (char const *const *) gccattr_noreturn ;
+extern void live_status (char const *const *) gccattr_noreturn ;
+extern void live_stop (char const *const *) gccattr_noreturn ;
-struct process_command_s
-{
- char const *s ;
- process_command_func_ref f ;
-} ;
-#define PROCESS_COMMAND_ZERO { .s = 0, .f = 0 }
+
+ /* process */
extern void process_check_services (char const *const *, size_t) ;
extern void process_send_svc (char const *, char const *const *, unsigned int, unsigned int) gccattr_noreturn ;
-extern void process_help (char const *const *, process_options const *) ;
-extern void process_kill (char const *const *, process_options const *) gccattr_noreturn ;
-extern void process_restart (char const *const *, process_options const *) gccattr_noreturn ;
-extern void process_start (char const *const *, process_options const *) gccattr_noreturn ;
-extern void process_stop (char const *const *, process_options const *) gccattr_noreturn ;
-extern void process_status (char const *const *, process_options const *) ;
-
-extern int process (char const *const *) ;
+extern void process (char const *const *) gccattr_noreturn ;
+extern void process_help (char const *const *) gccattr_noreturn ;
+extern void process_kill (char const *const *) gccattr_noreturn ;
+extern void process_restart (char const *const *) gccattr_noreturn ;
+extern void process_start (char const *const *) gccattr_noreturn ;
+extern void process_stop (char const *const *) gccattr_noreturn ;
+extern void process_status (char const *const *) gccattr_noreturn ;
/* service */
-extern int service_help (char const *const *) ;
-extern int service_start (char const *const *) ;
-extern int service_status (char const *const *) ;
-extern int service_stop (char const *const *) ;
-
-extern int service (char const *const *) ;
+extern void service (char const *const *) gccattr_noreturn ;
+extern void service_help (char const *const *) gccattr_noreturn ;
/* main */
@@ -105,7 +94,7 @@ struct modif_s
extern struct modif_s const cleanup_modif ;
-typedef int command_func (char const *const *) ;
+typedef void command_func (char const *const *) ;
typedef command_func *command_func_ref ;
struct command_s
diff --git a/src/s6-frontend/s6-frontend.c b/src/s6-frontend/s6-frontend.c
index ab4b045..ddc4eb2 100644
--- a/src/s6-frontend/s6-frontend.c
+++ b/src/s6-frontend/s6-frontend.c
@@ -18,7 +18,7 @@
#define USAGE "s6 [ generic options ] command [ command options ] command_arguments... Type \"s6 help\" for details."
#define dieusage() strerr_dieusage(100, USAGE)
-#define CLEANUP_MODIF "scandir\0livedir\0repodir\0bootdb\0stmpdir\0verbosity"
+#define CLEANUP_MODIF "scandir\0livedir\0repodir\0bootdb\0stmpdir\0verbosity\0defaultbundle"
struct modif_s const cleanup_modif =
{
.s = CLEANUP_MODIF,
@@ -134,5 +134,5 @@ int main (int argc, char const *const *argv)
if (!*argv) dieusage() ;
cmd = BSEARCH(struct command_s, *argv, commands) ;
if (!cmd) dieusage() ;
- return (*cmd->f)(++argv) ;
+ (*cmd->f)(++argv) ;
}
diff --git a/src/s6-frontend/service.c b/src/s6-frontend/service.c
index ef56339..028aee0 100644
--- a/src/s6-frontend/service.c
+++ b/src/s6-frontend/service.c
@@ -1,28 +1,30 @@
/* ISC license. */
-#include <skalibs/prog.h>
+#include <unistd.h>
+
#include <skalibs/strerr.h>
+#include <skalibs/gol.h>
#include "s6-frontend-internal.h"
#define USAGE "s6 service [ service options ] subcommand [ subcommand options ] services... Type \"s6 service help\" for details."
#define dieusage() strerr_dieusage(100, USAGE)
-static struct command_s const service_commands[] =
-{
- { .s = "help", .f = &service_help },
- { .s = "start", .f = &service_start },
- { .s = "status", .f = &service_status },
- { .s = "stop", .f = &service_stop },
-} ;
-
-int service (char const *const *argv)
+void service (char const *const *argv)
{
+ static struct command_s const commands[] =
+ {
+ { .s = "help", .f = &service_help },
+// { .s = "start", .f = &service_start },
+// { .s = "status", .f = &service_status },
+// { .s = "stop", .f = &service_stop },
+ } ;
struct command_s *cmd ;
- PROG = "s6-frontend: service" ;
+ argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ;
if (!*argv) dieusage() ;
- cmd = BSEARCH(struct command_s, *argv, service_commands) ;
+ cmd = BSEARCH(struct command_s, *argv, commands) ;
if (!cmd) dieusage() ;
- return (*cmd->f)(++argv) ;
+ (*cmd->f)(++argv) ;
+ _exit(101) ;
}
diff --git a/src/s6-frontend/service_help.c b/src/s6-frontend/service_help.c
index 304901a..d0d0d0a 100644
--- a/src/s6-frontend/service_help.c
+++ b/src/s6-frontend/service_help.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <unistd.h>
+
#include <skalibs/buffer.h>
#include <skalibs/strerr.h>
@@ -7,10 +9,10 @@
#define SERVICE_HELP_MESSAGE "This is the service help message.\n"
-int service_help (char const *const *argv)
+void service_help (char const *const *argv)
{
(void)argv ;
if (!buffer_putsflush(buffer_1, SERVICE_HELP_MESSAGE))
strerr_diefu1sys(111, "write to stdout") ;
- return 0 ;
+ _exit(0) ;
}
diff --git a/src/s6-frontend/service_status.c b/src/s6-frontend/service_status.c
deleted file mode 100644
index 85ab4b2..0000000
--- a/src/s6-frontend/service_status.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/uint64.h>
-#include <skalibs/strerr.h>
-#include <skalibs/gol.h>
-
-#include "s6-frontend-internal.h"
-
-#define USAGE "s6 service status services..."
-#define dieusage() strerr_dieusage(100, USAGE)
-
-enum golb_e
-{
- GOLB_WAIT,
- GOLB_N
-} ;
-
-static gol_bool const rgolb[2] =
-{
- { .so = 'w', .lo = "wait", .clear = 0, .set = 1 << GOLB_WAIT }
-} ;
-
-int service_status (char const *const *argv)
-{
- uint64_t wgolb = 0 ;
- PROG = "s6 service status" ;
-
- argv += gol_argv(argv, rgolb, 0, 0, 0, &wgolb, 0) ;
- if (!argv) dieusage() ;
- return 0 ;
-}