diff options
author | Alexander Vickberg <wickbergster@gmail.com> | 2019-04-27 15:42:41 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-27 15:43:43 +0200 |
commit | 100fa20c68564311cef8f625bcb1b423e96c97d6 (patch) | |
tree | 19f01d9e6f4fc35324707f8838de161593516cb6 /debianutils | |
parent | 1e9a4f56f574471707244db9f7038ad0581dec16 (diff) |
start-stop-daemon: Fix -x is not required for -K
Commit 088fec36fedff2cd50437c95b7fb430abf8d303c 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>
Diffstat (limited to 'debianutils')
-rw-r--r-- | debianutils/start_stop_daemon.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index 3a4c1044a..72642ae74 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c @@ -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,31 +452,34 @@ 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 (!execname) { /* -x is not given */ - execname = startas; - if (!execname) { /* neither -x nor -a is given */ - execname = argv[0]; - if (!execname) - bb_show_usage(); - argv++; + if (opt & CTX_START) { + if (!execname) { /* -x is not given */ + execname = startas; + if (!execname) { /* neither -x nor -a is given */ + execname = argv[0]; + if (!execname) + bb_show_usage(); + 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 (!startas) /* -a is not given: use -x EXECUTABLE or argv[0] */ - startas = execname; - *--argv = startas; - 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); |