aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/s6-frontend/live_status.c45
-rw-r--r--src/s6-frontend/live_stop_everything.c5
2 files changed, 33 insertions, 17 deletions
diff --git a/src/s6-frontend/live_status.c b/src/s6-frontend/live_status.c
index a68d99f..dbf9aa6 100644
--- a/src/s6-frontend/live_status.c
+++ b/src/s6-frontend/live_status.c
@@ -17,12 +17,12 @@
#include <s6-frontend/config.h>
#include "s6-frontend-internal.h"
-#define USAGE "s6 live status services..."
+#define USAGE "s6 live status [ -e | -E ] services..."
#define dieusage() strerr_dieusage(100, USAGE)
#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
-static void live_status_all (void) gccattr_noreturn ;
-static void live_status_all (void)
+static void live_status_all (int withe) gccattr_noreturn ;
+static void live_status_all (int withe)
{
char const *argv[23] ;
unsigned int m = 0 ;
@@ -40,7 +40,7 @@ static void live_status_all (void)
argv[m++] = EXECLINE_EXTBINPREFIX "if" ;
argv[m++] = " " EXECLINE_EXTBINPREFIX "pipeline" ;
argv[m++] = " " S6RC_EXTBINPREFIX "s6-rc" ;
- argv[m++] = " -ua" ;
+ argv[m++] = withe ? " -buaE" : " -buae" ;
argv[m++] = " list" ;
argv[m++] = " " ;
argv[m++] = " sed" ;
@@ -48,7 +48,7 @@ static void live_status_all (void)
argv[m++] = "" ;
argv[m++] = EXECLINE_EXTBINPREFIX "pipeline" ;
argv[m++] = " " S6RC_EXTBINPREFIX "s6-rc" ;
- argv[m++] = " -da" ;
+ argv[m++] = withe ? " -bdaE" : " -bdae" ;
argv[m++] = " list" ;
argv[m++] = "" ;
argv[m++] = "sed" ;
@@ -57,13 +57,13 @@ static void live_status_all (void)
xmexec_n(argv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
}
-static int get_list_of_up (stralloc *storage)
+static int get_list_of_up (stralloc *storage, int withe)
{
int swasnull = !storage->s ;
size_t sabase = storage->len ;
int fd ;
int wstat ;
- char const *argv[7] = { S6RC_EXTBINPREFIX "s6-rc", "-l", g->dirs.live, "-ba", "--", "list", 0 } ;
+ char const *argv[7] = { S6RC_EXTBINPREFIX "s6-rc", "-l", g->dirs.live, withe ? "-baE" : "-bae", "--", "list", 0 } ;
pid_t pid = child_spawn1_pipe(argv[0], argv, (char const *const *)environ, &fd, 1) ;
if (!pid) { strerr_warnfu2sys("spawn ", argv[0]) ; return 111 ; }
if (!slurpn(fd, storage, 0)) { strerr_warnfu2sys("read output from ", argv[0]) ; return 111 ; }
@@ -88,7 +88,7 @@ static int get_list_of_up (stralloc *storage)
return 111 ;
}
-static int get_atomics (char const *const *services, unsigned int n, stralloc *storage)
+static int get_atomics (char const *const *services, unsigned int n, stralloc *storage, int withe)
{
int swasnull = !storage->s ;
size_t sabase = storage->len ;
@@ -100,7 +100,7 @@ static int get_atomics (char const *const *services, unsigned int n, stralloc *s
argv[m++] = S6RC_EXTBINPREFIX "s6-rc-db" ;
argv[m++] = "-l";
argv[m++] = g->dirs.live ;
- argv[m++] = "-b" ;
+ argv[m++] = withe ? "-bE" : "-be" ;
argv[m++] = "--" ;
argv[m++] = "atomics" ;
for (unsigned int i = 0 ; i < n ; i++) argv[m++] = services[i] ;
@@ -129,8 +129,8 @@ static int get_atomics (char const *const *services, unsigned int n, stralloc *s
return 111 ;
}
-static void live_status_some (char const *const *services) gccattr_noreturn ;
-static void live_status_some (char const *const *services)
+static void live_status_some (char const *const *services, int withe) gccattr_noreturn ;
+static void live_status_some (char const *const *services, int withe)
{
stralloc sa = STRALLOC_ZERO ;
unsigned int m = 0 ;
@@ -138,11 +138,11 @@ static void live_status_some (char const *const *services)
int e ;
char const *argv[59] ;
if (!stralloc_catb(&sa, " ", 1)) dienomem() ;
- e = get_atomics(services, env_len(services), &sa) ;
+ e = get_atomics(services, env_len(services), &sa, withe) ;
if (e) _exit(e) ;
if (!stralloc_catb(&sa, "\0 ", 3)) dienomem() ;
uplistpos = sa.len ;
- e = get_list_of_up(&sa) ;
+ e = get_list_of_up(&sa, withe) ;
if (e) _exit(e) ;
if (!stralloc_0(&sa)) dienomem() ;
@@ -213,10 +213,23 @@ static void live_status_some (char const *const *services)
xmexec_n(argv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
}
+enum golb_e
+{
+ GOLB_INCLUDE_ESSENTIALS = 0x01,
+} ;
+
+
void live_status (char const *const *argv)
{
- argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ;
- if (!argv) live_status_all() ;
- else live_status_some(argv) ;
+ static gol_bool const rgolb[] =
+ {
+ { .so = 'e', .lo = "without-essentials", .clear = GOLB_INCLUDE_ESSENTIALS, .set = 0 },
+ { .so = 'E', .lo = "with-essentials", .clear = 0, .set = GOLB_INCLUDE_ESSENTIALS },
+ } ;
+ uint64_t wgolb = 0 ;
+
+ argv += gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ;
+ if (!argv) live_status_all(wgolb & GOLB_INCLUDE_ESSENTIALS) ;
+ else live_status_some(argv, wgolb & GOLB_INCLUDE_ESSENTIALS) ;
_exit(0) ;
}
diff --git a/src/s6-frontend/live_stop_everything.c b/src/s6-frontend/live_stop_everything.c
index 7d98c70..be9a40a 100644
--- a/src/s6-frontend/live_stop_everything.c
+++ b/src/s6-frontend/live_stop_everything.c
@@ -9,6 +9,7 @@
enum golb_e
{
GOLB_DRYRUN = 0x01,
+ GOLB_INCLUDE_ESSENTIALS = 0x02,
} ;
enum gola_e
@@ -22,6 +23,8 @@ void live_stop_everything (char const *const *argv)
static gol_bool const rgolb[] =
{
{ .so = 'n', .lo = "dry-run", .clear = 0, .set = GOLB_DRYRUN },
+ { .so = 'e', .lo = "without-essentials", .clear = GOLB_INCLUDE_ESSENTIALS, .set = 0 },
+ { .so = 'E', .lo = "with-essentials", .clear = 0, .set = GOLB_INCLUDE_ESSENTIALS },
} ;
static gol_arg const rgola[] =
{
@@ -56,7 +59,7 @@ void live_stop_everything (char const *const *argv)
if (wgolb & GOLB_DRYRUN) newargv[m++] = "-n1" ;
newargv[m++] = "-l" ;
newargv[m++] = g->dirs.live ;
- newargv[m++] = "-bda" ;
+ newargv[m++] = wgolb & GOLB_INCLUDE_ESSENTIALS ? "-bDa" : "-bda" ;
newargv[m++] = "--" ;
newargv[m++] = "change" ;
newargv[m++] = 0 ;