From: Clemens Buchacher Date: Wed, 04 Jan 2012 15:55:36 GMT Subject: [PATCH 3/6] avoid use of pkill Message-ID: <1325692539-26748-4-git-send-email-drizzd@aon.at> In-Reply-To: <1325692539-26748-1-git-send-email-drizzd@aon.at> --- t/lib-daemon.sh | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/t/lib-daemon.sh b/t/lib-daemon.sh index 30a89ea..5edced5 100644 --- a/t/lib-daemon.sh +++ b/t/lib-daemon.sh @@ -31,6 +31,24 @@ start_daemon() { DAEMON_PID=$! } +kill_children() { + parent=$1 + + ps -A -o ppid,pid | + ( + # skip header + read + while read ppid pid + do + if test x"$ppid" = x"$parent" + then + echo "$pid" + fi + done + ) | + xargs kill +} + stop_daemon() { if test -z "$DAEMON_PID" then @@ -41,7 +59,7 @@ stop_daemon() { # kill git-daemon child of git say >&3 "Stopping git daemon ..." - pkill -P "$DAEMON_PID" + kill_children "$DAEMON_PID" wait "$DAEMON_PID" ret=$? if test $ret -ne 143 -- 1.7.8