mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
initctl: Fix error handling for intictl start/stop if missing arg
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
d94d11e00a
commit
7362e6d00a
1 file changed
+3
-17
+3
-17
@@ -160,28 +160,14 @@ static int missing(char *job, int id)
|
|||||||
*/
|
*/
|
||||||
static int do_startstop(int cmd, char *arg)
|
static int do_startstop(int cmd, char *arg)
|
||||||
{
|
{
|
||||||
int ret;
|
/* Include \0 in len, needed by parser */
|
||||||
char *svcs;
|
if (svc_parse_jobstr(arg, strlen(arg) + 1, NULL, missing)) {
|
||||||
|
fprintf(stderr, "Usage: initctl %s <JOB|NAME>[:ID]\n",
|
||||||
if (!arg) {
|
|
||||||
fprintf(stderr, "Usage: initctl %s <JOB|NAME>[:ID]",
|
|
||||||
cmd == INIT_CMD_START_SVC ? "start" :
|
cmd == INIT_CMD_START_SVC ? "start" :
|
||||||
(cmd == INIT_CMD_STOP_SVC ? "stop" : "restart"));
|
(cmd == INIT_CMD_STOP_SVC ? "stop" : "restart"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
svcs = strdup(arg);
|
|
||||||
if (!svcs) {
|
|
||||||
perror("Failed validating service(s) name");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Include \0 in len, needed by parser */
|
|
||||||
ret = svc_parse_jobstr(svcs, strlen(svcs) + 1, NULL, missing);
|
|
||||||
free(svcs);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return do_svc(cmd, arg);
|
return do_svc(cmd, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user