start-stop-daemon: fix "-K --test --pidfile PIDFILE" exitcode

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-04-04 02:03:35 +02:00
parent 6a3e01d5a9
commit 929f63e57c

View File

@ -337,11 +337,17 @@ static int do_stop(void)
goto ret; goto ret;
} }
for (p = G.found_procs; p; p = p->next) { for (p = G.found_procs; p; p = p->next) {
if (TEST || kill(p->pid, signal_nr) == 0) { if (kill(p->pid, TEST ? 0 : signal_nr) == 0) {
killed++; killed++;
} else { } else {
p->pid = 0;
bb_perror_msg("warning: killing process %u", (unsigned)p->pid); bb_perror_msg("warning: killing process %u", (unsigned)p->pid);
p->pid = 0;
if (TEST) {
/* Example: -K --test --pidfile PIDFILE detected
* that PIDFILE's pid doesn't exist */
killed = -1;
goto ret;
}
} }
} }
if (!QUIET && killed) { if (!QUIET && killed) {