From 6bdd9f89673e694df8a1bac6c129b21739ed8a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= Date: Thu, 7 Feb 2013 22:35:57 +0000 Subject: MAKEALL: fix kill_children for BSD hosts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ps on BSD hosts (like OS X) do not provide the --no-headers switch nor understand the AIX format descriptions. Unfortunately there seems no solution to get the PIDs of children in a platfrom independent manner. Therefore detect the OS and decide upon that which way to go. This patch makes the MAKEALL script cleanly stoppable on bare OS X when using the parallel builds of targets. Additionally this patch removes double call to grep by a single call to sed for GNU style child PID detection. Signed-off-by: Andreas Bießmann Cc: Joe Hershberger Acked-by: Joe Hershberger --- MAKEALL | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'MAKEALL') diff --git a/MAKEALL b/MAKEALL index 397adef920..c1d8957256 100755 --- a/MAKEALL +++ b/MAKEALL @@ -802,8 +802,20 @@ build_targets() { #----------------------------------------------------------------------- kill_children() { - local pgid=`ps -p $$ --no-headers -o "%r" | tr -d ' '` - local children=`pgrep -g $pgid | grep -v $$ | grep -v $pgid` + local OS=$(uname -s) + local children="" + case "${OS}" in + "Darwin") + # Mac OS X is known to have BSD style ps + local pgid=$(ps -p $$ -o pgid | sed -e "/PGID/d") + children=$(ps -g $pgid -o pid | sed -e "/PID\|$$\|$pgid/d") + ;; + *) + # everything else tries the GNU style + local pgid=$(ps -p $$ --no-headers -o "%r" | tr -d ' ') + children=$(pgrep -g $pgid | sed -e "/$$\|$pgid/d") + ;; + esac kill $children 2> /dev/null wait $children 2> /dev/null -- cgit v1.2.1