summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
m---------grecs0
-rw-r--r--src/pidfrom.c41
-rw-r--r--src/sentinel.c2
3 files changed, 28 insertions, 15 deletions
diff --git a/grecs b/grecs
-Subproject 27ca9f5819d0e44173a5f61a241cd066ad15713
+Subproject a531c7d1de4780ee53ffbd383329dfff55d425b
diff --git a/src/pidfrom.c b/src/pidfrom.c
index d1fa627..371e692 100644
--- a/src/pidfrom.c
+++ b/src/pidfrom.c
@@ -8,15 +8,16 @@ There is NO WARRANTY, to the extent permitted by law.
struct genrc_pid_source {
char *name;
+ size_t maxwords;
GENRC_PID_CLOSURE *(*init)(int argc, char **argv);
};
struct genrc_pid_source sourcetab[] = {
- { "FILE", genrc_pid_file_init },
- { "CONFIG", genrc_pid_config_init },
- { "GREP", genrc_pid_grep_init },
- { "PROC", genrc_pid_proc_init },
- { "PS", genrc_pid_ps_init },
+ { "FILE", 2, genrc_pid_file_init },
+ { "CONFIG", 4, genrc_pid_config_init },
+ { "GREP", 3, genrc_pid_grep_init },
+ { "PROC", 3, genrc_pid_proc_init },
+ { "PS", 3, genrc_pid_ps_init },
{ NULL }
};
@@ -26,22 +27,34 @@ get_pid_closure(char const *str)
struct genrc_pid_source *s;
struct wordsplit ws;
GENRC_PID_CLOSURE *pc;
+ size_t len = strcspn(str, ":");
+ int wsflags;
- ws.ws_error = genrc_error;
- ws.ws_delim = ":";
- if (wordsplit(str, &ws,
- WRDSF_NOCMD|WRDSF_NOVAR|WRDSF_QUOTE|
- WRDSF_DELIM|WRDSF_ENOMEMABRT|WRDSF_SHOWERR|WRDSF_ERROR))
- exit(1);
-
- if (ws.ws_wordc == 0)
+ if (len == 0)
usage_error("GENRC_PID_FROM argument is empty");
for (s = sourcetab; ; s++) {
if (!s->name)
usage_error("%s: unsupported PID source", str);
- if (strcmp(s->name, ws.ws_wordv[0]) == 0)
+ if (strlen(s->name) == len && memcmp(s->name, str, len) == 0)
break;
}
+
+ ws.ws_error = genrc_error;
+ ws.ws_delim = ":";
+ wsflags = WRDSF_NOCMD
+ | WRDSF_NOVAR
+ | WRDSF_QUOTE
+ | WRDSF_DELIM
+ | WRDSF_ENOMEMABRT
+ | WRDSF_SHOWERR
+ | WRDSF_ERROR;
+ if (s->maxwords) {
+ ws.ws_maxwords = s->maxwords;
+ ws.ws_options = WRDSO_MAXWORDS;
+ wsflags |= WRDSF_OPTIONS;
+ }
+ if (wordsplit(str, &ws, wsflags))
+ exit(1);
pc = s->init(ws.ws_wordc, ws.ws_wordv);
if (!pc)
exit(1);
diff --git a/src/sentinel.c b/src/sentinel.c
index 33d3e06..4f269b8 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -200,7 +200,7 @@ wait_loop(pid_t child, int out, int err)
genrc_program, WSTOPSIG(status));
} else {
syslog(LOG_INFO, "%s terminated; status %d",
- genrc_program, rc);
+ genrc_program, status);
}
break;
}

Return to:

Send suggestions and report system problems to the System administrator.