[PATCH 3/6] avoid use of pkill
---
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