[git commit /heads/master] start-stop-daemon: fix "-K --test --pidfile PIDFILE" exitcode

Denys Vlasenko vda.linux at googlemail.com
Mon Apr 4 00:03:35 UTC 2011


commit: http://git.busybox.net/busybox/commit/?id=929f63e57cadb22905411f212809c14b160ec494
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 debianutils/start_stop_daemon.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 30dd970..bc61959 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -337,11 +337,17 @@ static int do_stop(void)
 		goto ret;
 	}
 	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++;
 		} else {
-			p->pid = 0;
 			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) {
-- 
1.7.3.4



More information about the busybox-cvs mailing list