diff options
Diffstat (limited to 'debianutils/start_stop_daemon.c')
-rw-r--r-- | debianutils/start_stop_daemon.c | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index d2ee95068..bc61959d2 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c | |||
@@ -56,6 +56,69 @@ Misc options: | |||
56 | -v,--verbose Verbose | 56 | -v,--verbose Verbose |
57 | */ | 57 | */ |
58 | 58 | ||
59 | //usage:#define start_stop_daemon_trivial_usage | ||
60 | //usage: "[OPTIONS] [-S|-K] ... [-- ARGS...]" | ||
61 | //usage:#define start_stop_daemon_full_usage "\n\n" | ||
62 | //usage: "Search for matching processes, and then\n" | ||
63 | //usage: "-K: stop all matching processes.\n" | ||
64 | //usage: "-S: start a process unless a matching process is found.\n" | ||
65 | //usage: IF_FEATURE_START_STOP_DAEMON_LONG_OPTIONS( | ||
66 | //usage: "\nProcess matching:" | ||
67 | //usage: "\n -u,--user USERNAME|UID Match only this user's processes" | ||
68 | //usage: "\n -n,--name NAME Match processes with NAME" | ||
69 | //usage: "\n in comm field in /proc/PID/stat" | ||
70 | //usage: "\n -x,--exec EXECUTABLE Match processes with this command" | ||
71 | //usage: "\n in /proc/PID/cmdline" | ||
72 | //usage: "\n -p,--pidfile FILE Match a process with PID from the file" | ||
73 | //usage: "\n All specified conditions must match" | ||
74 | //usage: "\n-S only:" | ||
75 | //usage: "\n -x,--exec EXECUTABLE Program to run" | ||
76 | //usage: "\n -a,--startas NAME Zeroth argument" | ||
77 | //usage: "\n -b,--background Background" | ||
78 | //usage: IF_FEATURE_START_STOP_DAEMON_FANCY( | ||
79 | //usage: "\n -N,--nicelevel N Change nice level" | ||
80 | //usage: ) | ||
81 | //usage: "\n -c,--chuid USER[:[GRP]] Change to user/group" | ||
82 | //usage: "\n -m,--make-pidfile Write PID to the pidfile specified by -p" | ||
83 | //usage: "\n-K only:" | ||
84 | //usage: "\n -s,--signal SIG Signal to send" | ||
85 | //usage: "\n -t,--test Match only, exit with 0 if a process is found" | ||
86 | //usage: "\nOther:" | ||
87 | //usage: IF_FEATURE_START_STOP_DAEMON_FANCY( | ||
88 | //usage: "\n -o,--oknodo Exit with status 0 if nothing is done" | ||
89 | //usage: "\n -v,--verbose Verbose" | ||
90 | //usage: ) | ||
91 | //usage: "\n -q,--quiet Quiet" | ||
92 | //usage: ) | ||
93 | //usage: IF_NOT_FEATURE_START_STOP_DAEMON_LONG_OPTIONS( | ||
94 | //usage: "\nProcess matching:" | ||
95 | //usage: "\n -u USERNAME|UID Match only this user's processes" | ||
96 | //usage: "\n -n NAME Match processes with NAME" | ||
97 | //usage: "\n in comm field in /proc/PID/stat" | ||
98 | //usage: "\n -x EXECUTABLE Match processes with this command" | ||
99 | //usage: "\n command in /proc/PID/cmdline" | ||
100 | //usage: "\n -p FILE Match a process with PID from the file" | ||
101 | //usage: "\n All specified conditions must match" | ||
102 | //usage: "\n-S only:" | ||
103 | //usage: "\n -x EXECUTABLE Program to run" | ||
104 | //usage: "\n -a NAME Zeroth argument" | ||
105 | //usage: "\n -b Background" | ||
106 | //usage: IF_FEATURE_START_STOP_DAEMON_FANCY( | ||
107 | //usage: "\n -N N Change nice level" | ||
108 | //usage: ) | ||
109 | //usage: "\n -c USER[:[GRP]] Change to user/group" | ||
110 | //usage: "\n -m Write PID to the pidfile specified by -p" | ||
111 | //usage: "\n-K only:" | ||
112 | //usage: "\n -s SIG Signal to send" | ||
113 | //usage: "\n -t Match only, exit with 0 if a process is found" | ||
114 | //usage: "\nOther:" | ||
115 | //usage: IF_FEATURE_START_STOP_DAEMON_FANCY( | ||
116 | //usage: "\n -o Exit with status 0 if nothing is done" | ||
117 | //usage: "\n -v Verbose" | ||
118 | //usage: ) | ||
119 | //usage: "\n -q Quiet" | ||
120 | //usage: ) | ||
121 | |||
59 | #include <sys/resource.h> | 122 | #include <sys/resource.h> |
60 | 123 | ||
61 | /* Override ENABLE_FEATURE_PIDFILE */ | 124 | /* Override ENABLE_FEATURE_PIDFILE */ |
@@ -274,11 +337,17 @@ static int do_stop(void) | |||
274 | goto ret; | 337 | goto ret; |
275 | } | 338 | } |
276 | for (p = G.found_procs; p; p = p->next) { | 339 | for (p = G.found_procs; p; p = p->next) { |
277 | if (TEST || kill(p->pid, signal_nr) == 0) { | 340 | if (kill(p->pid, TEST ? 0 : signal_nr) == 0) { |
278 | killed++; | 341 | killed++; |
279 | } else { | 342 | } else { |
280 | p->pid = 0; | ||
281 | bb_perror_msg("warning: killing process %u", (unsigned)p->pid); | 343 | bb_perror_msg("warning: killing process %u", (unsigned)p->pid); |
344 | p->pid = 0; | ||
345 | if (TEST) { | ||
346 | /* Example: -K --test --pidfile PIDFILE detected | ||
347 | * that PIDFILE's pid doesn't exist */ | ||
348 | killed = -1; | ||
349 | goto ret; | ||
350 | } | ||
282 | } | 351 | } |
283 | } | 352 | } |
284 | if (!QUIET && killed) { | 353 | if (!QUIET && killed) { |