sm

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

commit 36ef650ded2f766e1c20762f63683d8add319eee
parent 3839eedb7ca1eca5b59a53b392a2b4cccfaf2008
Author: Cem Keylan <cem@ckyln.com>
Date:   Sat, 10 Oct 2020 11:47:54 +0300

svctl: do not exit during 'status' call when service is down.

Diffstat:
Msvctl.c | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/svctl.c b/svctl.c @@ -90,7 +90,7 @@ int handle_service(char *operation, char *name) } else if (strcmp(operation, "stat") == 0 || strcmp(operation, "status") == 0) { if (sv_check(&sv, 1) < 0) { fprintf(stderr, "%s: DOWN\n", name); - exit(1); + return -1; } else fprintf(stderr, "%s: UP\n", name); } else @@ -103,7 +103,7 @@ main(int argc, char *argv[]) { char *rundir; argv0 = argv[0]; - int i; + int i, exitnum; if (argc < 2 || strncmp(argv[1], "-", 1) == 0) usage(0); @@ -115,6 +115,14 @@ main(int argc, char *argv[]) if (check_rundir(rundir) != 0) die("%s could not be found, are you sure sysmgr is running?", rundir); + if (strncmp(argv[1], "stat", 4) == 0) { + exitnum = 0; + for (i=2; i < argc; i++) + if(handle_service(argv[1], argv[i]) != 0) + exitnum = 1; + exit(exitnum); + } + for (i=2; i < argc; i++) if (handle_service(argv[1], argv[i]) != 0) die("Couldn't %s %s", argv[1], argv[i]);