diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/helpers/deps-exe/s6-frontend-helper-echo | 1 | ||||
| -rw-r--r-- | src/helpers/s6-frontend-helper-echo.c | 54 | ||||
| -rw-r--r-- | src/s6-frontend/live_status.c | 16 | ||||
| -rw-r--r-- | src/s6-frontend/process_startstop.c | 2 |
4 files changed, 65 insertions, 8 deletions
diff --git a/src/helpers/deps-exe/s6-frontend-helper-echo b/src/helpers/deps-exe/s6-frontend-helper-echo new file mode 100644 index 0000000..e7187fe --- /dev/null +++ b/src/helpers/deps-exe/s6-frontend-helper-echo @@ -0,0 +1 @@ +-lskarnet diff --git a/src/helpers/s6-frontend-helper-echo.c b/src/helpers/s6-frontend-helper-echo.c new file mode 100644 index 0000000..5d416bd --- /dev/null +++ b/src/helpers/s6-frontend-helper-echo.c @@ -0,0 +1,54 @@ +/* ISC license. */ + +#include <unistd.h> + +#include <skalibs/uint64.h> +#include <skalibs/buffer.h> +#include <skalibs/envexec.h> + +#define USAGE "s6-frontend-helper-echo [ -n ] [ -s sep ] args..." + +enum golb_e +{ + GOLB_CHOMP = 0x01, +} ; + +enum gola_e +{ + GOLA_SEP, + GOLA_N +} ; + +int main (int argc, char const *const *argv) +{ + static gol_bool const rgolb[] = + { + { .so = 'n', .lo = "chomp", .clear = 0, .set = GOLB_CHOMP }, + } ; + static gol_arg const rgola[] = + { + { .so = 's', .lo = "separator", .i = GOLA_SEP }, + } ; + uint64_t wgolb = 0 ; + char const *wgola[GOLA_N] = { [GOLA_SEP] = " " } ; + PROG = "s6-frontend-helper-echo" ; + { + unsigned int golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ; + argc -= golc ; argv += golc ; + } + + for (; *argv ; argv++) + { + if (buffer_puts(buffer_1small, *argv) == -1) goto err ; + if (argv[1] && buffer_put(buffer_1small, wgola[GOLA_SEP], 1) == -1) goto err ; + } + if (!(wgolb & GOLB_CHOMP)) + { + if (buffer_put(buffer_1small, "\n", 1) == -1) goto err ; + } + if (!buffer_flush(buffer_1small)) goto err ; + _exit(0) ; + +err: + strerr_diefu1sys(111, "write to stdout") ; +} diff --git a/src/s6-frontend/live_status.c b/src/s6-frontend/live_status.c index 2a3a9af..4a7711a 100644 --- a/src/s6-frontend/live_status.c +++ b/src/s6-frontend/live_status.c @@ -138,7 +138,7 @@ static void live_status_some (char const *const *services, int withe) unsigned int m = 0 ; size_t uplistpos ; int e ; - char const *argv[53] ; + char const *argv[55] ; if (!stralloc_catb(&sa, " ", 1)) dienomem() ; e = get_atomics(services, env_len(services), &sa, withe) ; if (e) _exit(e) ; @@ -158,8 +158,8 @@ static void live_status_some (char const *const *services, int withe) argv[m++] = " " EXECLINE_EXTBINPREFIX "fdmove" ; argv[m++] = " 1" ; argv[m++] = " 4" ; - argv[m++] = " " EXECLINE_EXTBINPREFIX "heredoc" ; - argv[m++] = " 0" ; + argv[m++] = " " S6_FRONTEND_LIBEXECPREFIX "s6-frontend-helper-echo" ; + argv[m++] = " --" ; argv[m++] = sa.s + uplistpos - 2 ; argv[m++] = " " ; argv[m++] = " " EXECLINE_EXTBINPREFIX "fdclose" ; @@ -169,7 +169,8 @@ static void live_status_some (char const *const *services, int withe) argv[m++] = sa.s ; argv[m++] = " " EXECLINE_EXTBINPREFIX "pipeline" ; argv[m++] = " grep" ; - argv[m++] = " -Fxf" ; + argv[m++] = " -Fx" ; + argv[m++] = " -f" ; argv[m++] = " /dev/fd/3" ; argv[m++] = " " ; argv[m++] = " sed" ; @@ -184,8 +185,8 @@ static void live_status_some (char const *const *services, int withe) argv[m++] = " " EXECLINE_EXTBINPREFIX "fdmove" ; argv[m++] = " 1" ; argv[m++] = " 4" ; - argv[m++] = " " EXECLINE_EXTBINPREFIX "heredoc" ; - argv[m++] = " 0" ; + argv[m++] = " " S6_FRONTEND_LIBEXECPREFIX "s6-frontend-helper-echo" ; + argv[m++] = " --" ; argv[m++] = sa.s + uplistpos - 1 ; argv[m++] = "" ; argv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ; @@ -195,7 +196,8 @@ static void live_status_some (char const *const *services, int withe) argv[m++] = sa.s + 1 ; argv[m++] = EXECLINE_EXTBINPREFIX "pipeline" ; argv[m++] = " grep" ; - argv[m++] = " -Fxf" ; + argv[m++] = " -Fx" ; + argv[m++] = " -f" ; argv[m++] = " /dev/fd/3" ; argv[m++] = "" ; argv[m++] = "sed" ; diff --git a/src/s6-frontend/process_startstop.c b/src/s6-frontend/process_startstop.c index 9df5f96..511bde7 100644 --- a/src/s6-frontend/process_startstop.c +++ b/src/s6-frontend/process_startstop.c @@ -48,7 +48,7 @@ static void process_startstop (char const *const *argv, int h, char const *usage } argc = env_len(argv) ; process_check_services(argv, argc) ; - process_send_svc(svcopts[wgolb & (GOLB_PERMANENT|GOLB_WAIT) | h], argv, argc, timeout) ; + process_send_svc(svcopts[(wgolb & (GOLB_PERMANENT|GOLB_WAIT)) | h], argv, argc, timeout) ; } void process_start (char const *const *argv) |
