All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Bießmann" <andreas.devel@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] MAKEALL: fix kill_children for BSD hosts
Date: Fri,  8 Feb 2013 08:35:57 +0000	[thread overview]
Message-ID: <1360312557-25604-1-git-send-email-andreas.devel@googlemail.com> (raw)
In-Reply-To: <1358898669-21682-1-git-send-email-andreas.devel@googlemail.com>

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 <andreas.devel@googlemail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---
 MAKEALL |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/MAKEALL b/MAKEALL
index 5b06c54..1dffa1a 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -784,8 +784,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
-- 
1.7.10.4

  parent reply	other threads:[~2013-02-08  8:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-22 23:51 [U-Boot] [PATCH] MAKEALL: fix kill_children for BSD hosts Andreas Bießmann
2013-01-23 11:28 ` Andreas Bießmann
2013-02-08  8:35 ` Andreas Bießmann [this message]
2013-02-08 20:52   ` [U-Boot] [PATCH v2] " Joe Hershberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360312557-25604-1-git-send-email-andreas.devel@googlemail.com \
    --to=andreas.devel@googlemail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.