sm

sysmgr implemented in C
git clone git://git.ckyln.com/sm
Log | Files | Refs | README | LICENSE

commit 468f73b04c1967c5a8f90e1e276ad4f59229f14a
parent 247813beabedf26ede4e9e143693b817c6c3e593
Author: Cem Keylan <cem@ckyln.com>
Date:   Sat, 10 Oct 2020 11:17:26 +0300

sysmgr-depends: add program to track dependencies

Diffstat:
MMakefile | 3++-
Asysmgr-depends.c | 42++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -20,7 +20,8 @@ LIBUTILSRC = \ BIN = \ sysmgr \ runsyssv \ - svctl + svctl \ + sysmgr-depends SRC = ${BIN:=.c} BINOBJ = ${SRC:.c=.o} diff --git a/sysmgr-depends.c b/sysmgr-depends.c @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include "util.h" +#include "config.h" +static char *argv0; + +void +usage(void) +{ + printf("usage: %s [service...]\n\nsysmgr-%s\n", argv0, VERSION); + exit(0); +} + +int +main (int argc, char *argv[]) +{ + int i; + argv0 = argv[0]; + if (argc < 2 || strncmp(argv[1], "-", 1) == 0) + usage(); + + /* Make a check that the services are actually valid. */ + for (i=1; i < argc; i++) { + struct service sv; + sv_init(&sv, argv[i]); + if (access(sv.svfile, R_OK) < 0) + die("service file for '%s' could not be found", argv[i]); + } + + for (i=1; i < argc; i++) { + struct service sv; + sv_init(&sv, argv[i]); + while(1) { + if (sv_check(&sv, 1) == 0) + break; + sleep(1); + } + } +}