aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-11-07 06:55:35 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2023-11-07 06:55:35 +0100
commit0c71497e654fb5e9a9272f81ddb5d994d2839df4 (patch)
treeb94093cd60238c972dbbc03bf7cfe27965a83327
parente265c8d4c039729f2a68f3b1fb589c13c38d86f8 (diff)
downloadbusybox-w32-0c71497e654fb5e9a9272f81ddb5d994d2839df4.tar.gz
busybox-w32-0c71497e654fb5e9a9272f81ddb5d994d2839df4.tar.bz2
busybox-w32-0c71497e654fb5e9a9272f81ddb5d994d2839df4.zip
start-stop-daemon: fix --help: -K or -S is required
function old new delta .rodata 105381 105382 +1 packed_usage 34638 34602 -36 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 1/-36) Total: -35 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--debianutils/start_stop_daemon.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 3e5dd9faa..16df67b3e 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -11,11 +11,12 @@
11/* 11/*
12This is how it is supposed to work: 12This is how it is supposed to work:
13 13
14start-stop-daemon [OPTIONS] [--start|--stop] [[--] arguments...] 14start-stop-daemon [OPTIONS] [--start|--stop] [[--] ARGS...]
15 15
16One (only) of these must be given: 16One (only) of these must be given:
17 -S,--start Start 17 -S,--start Start
18 -K,--stop Stop 18 -K,--stop Stop
19 -T,--status Check for the existence of a process, return exitcode (since version 1.16.1)
19 20
20Search for matching processes. 21Search for matching processes.
21If --stop is given, stop all matching processes (by sending a signal). 22If --stop is given, stop all matching processes (by sending a signal).
@@ -36,20 +37,41 @@ with /proc/$PID/exe or argv[0] (comm can't be matched, it never contains path)]
36 Unlike -n, we match against the full path: 37 Unlike -n, we match against the full path:
37 "ntpd" != "./ntpd" != "/path/to/ntpd" 38 "ntpd" != "./ntpd" != "/path/to/ntpd"
38 -p,--pidfile PID_FILE Look for processes with PID from this file 39 -p,--pidfile PID_FILE Look for processes with PID from this file
40 --ppid PPID Look for processes with parent pid (since version 1.17.7)
39 41
40Options which are valid for --start only: 42Options which are valid for --start only:
41 -x,--exec EXECUTABLE Program to run (1st arg of execvp). Mandatory. 43 -x,--exec EXECUTABLE Program to run (1st arg of execvp).
44 If no -x, EXECUTABLE is taken from ARGS[0]
42 -a,--startas NAME argv[0] (defaults to EXECUTABLE) 45 -a,--startas NAME argv[0] (defaults to EXECUTABLE)
43 -b,--background Put process into background 46 -b,--background Put process into background
47 -O,--output FILE Redirect stdout and stderr to FILE when forcing the
48 daemon into the background (since version 1.20.6). Only
49 relevant when using --background.
50 Probably O_CREAT|O_TRUNC? What if execv fails - where does error msg go? "Old" stderr? FILE? Nowhere?
44 -N,--nicelevel N Add N to process' nice level 51 -N,--nicelevel N Add N to process' nice level
45 -c,--chuid USER[:[GRP]] Change to specified user [and group] 52 -c,--chuid USER[:[GRP]] Change to specified user [and group]
46 -m,--make-pidfile Write PID to the pidfile 53 -m,--make-pidfile Write PID to the pidfile
47 (both -m and -p must be given!) 54 (both -m and -p must be given!)
55 -P,--procsched policy:priority
56 This alters the process scheduler policy and priority of the
57 process before starting it (since version 1.15.0). The
58 priority can be optionally specified by appending a :
59 followed by the value. The default priority is 0. The
60 currently supported policy values are other, fifo and rr.
61 -r,--chroot root Change directory and chroot to root before starting the
62 process. Please note that the pidfile is also written after
63 the chroot.
64 -d,--chdir path Change directory to path before starting the process. This is
65 done after the chroot if the -r|--chroot option is set. When
66 not specified, start-stop-daemon will change directory to the
67 root directory before starting the process.
48 68
49Options which are valid for --stop only: 69Options which are valid for --stop only:
50 -s,--signal SIG Signal to send (default:TERM) 70 -s,--signal SIG Signal to send (default:TERM)
51 -t,--test Exit with status 0 if process is found 71 -t,--test Exit with status 0 if process is found
52 (we don't actually start or stop daemons) 72 (we don't actually start or stop daemons)
73 --remove-pidfile Used when stopping a program that does not remove its own pid
74 file (since version 1.17.19). Requires -p PIDFILE?
53 75
54Misc options: 76Misc options:
55 -o,--oknodo Exit with status 0 if nothing is done 77 -o,--oknodo Exit with status 0 if nothing is done
@@ -84,11 +106,11 @@ Misc options:
84//kbuild:lib-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o 106//kbuild:lib-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
85 107
86//usage:#define start_stop_daemon_trivial_usage 108//usage:#define start_stop_daemon_trivial_usage
87//usage: "[OPTIONS] [-S|-K] ... [-- ARGS...]" 109//usage: "-S|-K [OPTIONS] [-- ARGS...]"
88//usage:#define start_stop_daemon_full_usage "\n\n" 110//usage:#define start_stop_daemon_full_usage "\n\n"
89//usage: "Search for matching processes, and then\n" 111//usage: "Search for matching processes, and then\n"
90//usage: "-K: stop all matching processes\n"
91//usage: "-S: start a process unless a matching process is found\n" 112//usage: "-S: start a process unless a matching process is found\n"
113//usage: "-K: stop all matching processes\n"
92//usage: "\nProcess matching:" 114//usage: "\nProcess matching:"
93//usage: "\n -u USERNAME|UID Match only this user's processes" 115//usage: "\n -u USERNAME|UID Match only this user's processes"
94//usage: "\n -n NAME Match processes with NAME" 116//usage: "\n -n NAME Match processes with NAME"
@@ -422,15 +444,19 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
422 opt = GETOPT32(argv, "^" 444 opt = GETOPT32(argv, "^"
423 "KSbqtma:n:s:u:c:x:p:" 445 "KSbqtma:n:s:u:c:x:p:"
424 IF_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:") 446 IF_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:")
447 "\0"
448 "K:S:K--S:S--K"
425 /* -K or -S is required; they are mutually exclusive */ 449 /* -K or -S is required; they are mutually exclusive */
426 /* -p is required if -m is given */ 450 ":m?p" /* -p is required if -m is given */
427 /* -xpun (at least one) is required if -K is given */ 451 ":K?xpun" /* -xpun (at least one) is required if -K is given */
452 /* (the above does not seem to be enforced by Debian, it does nothing
453 * if no matching is specified with -K, and it ignores ARGS
454 * - does not take ARGS[0] as program name to kill)
455 */
428// /* -xa (at least one) is required if -S is given */ 456// /* -xa (at least one) is required if -S is given */
429//WRONG: "start-stop-daemon -S -- sleep 5" is a valid invocation 457//WRONG: "start-stop-daemon -S -- sleep 5" is a valid invocation
430 /* -q turns off -v */ 458 IF_FEATURE_START_STOP_DAEMON_FANCY(":q-v") /* -q turns off -v */
431 "\0" 459 ,
432 "K:S:K--S:S--K:m?p:K?xpun"
433 IF_FEATURE_START_STOP_DAEMON_FANCY("q-v"),
434 LONGOPTS 460 LONGOPTS
435 &startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile 461 &startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile
436 IF_FEATURE_START_STOP_DAEMON_FANCY(,&opt_N) 462 IF_FEATURE_START_STOP_DAEMON_FANCY(,&opt_N)