start-stop-daemon: Fix -x is not required for -K

Commit 088fec36fe made -x required for
all. However it isn't for -K.

function                                             old     new   delta
start_stop_daemon_main                              1084    1105     +21
packed_usage                                       33343   33326     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 21/-17)              Total: 4 bytes

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Alexander Vickberg 2019-04-27 15:42:41 +02:00 committed by Denys Vlasenko
parent 1e9a4f56f5
commit 100fa20c68

View File

@ -94,7 +94,7 @@ Misc options:
//usage: "\n -n NAME Match processes with NAME"
//usage: "\n in comm field in /proc/PID/stat"
//usage: "\n -x EXECUTABLE Match processes with this command"
//usage: "\n command in /proc/PID/cmdline"
//usage: "\n in /proc/PID/cmdline"
//usage: "\n -p FILE Match a process with PID from FILE"
//usage: "\n All specified conditions must match"
//usage: "\n-S only:"
@ -452,6 +452,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
// "start-stop-daemon -S -a sleep -- 5"
// NB: -n option does _not_ behave in this way: this will try to execute "5":
// "start-stop-daemon -S -n sleep -- 5"
if (opt & CTX_START) {
if (!execname) { /* -x is not given */
execname = startas;
if (!execname) { /* neither -x nor -a is given */
@ -464,19 +465,21 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
if (!startas) /* -a is not given: use -x EXECUTABLE or argv[0] */
startas = execname;
*--argv = startas;
}
if (execname) {
G.execname_sizeof = strlen(execname) + 1;
G.execname_cmpbuf = xmalloc(G.execname_sizeof + 1);
}
// IF_FEATURE_START_STOP_DAEMON_FANCY(
// if (retry_arg)
// retries = xatoi_positive(retry_arg);
// )
if (userspec) {
user_id = bb_strtou(userspec, NULL, 10);
if (errno)
user_id = xuname2uid(userspec);
}
/* Both start and stop need to know current processes */
do_procinit();
@ -485,6 +488,8 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
return (opt & OPT_OKNODO) ? 0 : (i <= 0);
}
/* else: CTX_START (-S). execname can't be NULL. */
if (G.found_procs) {
if (!QUIET)
printf("%s is already running\n", execname);