All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] MAKEALL: fix kill_children for BSD hosts
@ 2013-01-22 23:51 Andreas Bießmann
  2013-01-23 11:28 ` Andreas Bießmann
  2013-02-08  8:35 ` [U-Boot] [PATCH v2] " Andreas Bießmann
  0 siblings, 2 replies; 4+ messages in thread
From: Andreas Bießmann @ 2013-01-22 23:51 UTC (permalink / raw)
  To: u-boot

ps on BSD hosts (like OS X) do not provide the --no-headers switch nor
understand the AIX format descriptions. Make the call for ps portable and filter
the relevant line from output (including the header) with sed.
Also switch from pgrep to ps to get the list of children and use the same
mechanism as for pgid.

This patch makes the MAKEALL script cleanly stoppable on bare OS X when using
the parallel builds of targets.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---
 MAKEALL | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAKEALL b/MAKEALL
index 5b06c54..d926846 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -784,8 +784,8 @@ 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 pgid=`ps -p $$ -o pgid | sed -e "/PGID/d"`
+	local children=`ps -g $pgid -o pid | sed -e "/PID\|$$\|$pgid/d"`
 
 	kill $children 2> /dev/null
 	wait $children 2> /dev/null
-- 
1.8.1.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] MAKEALL: fix kill_children for BSD hosts
  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 ` [U-Boot] [PATCH v2] " Andreas Bießmann
  1 sibling, 0 replies; 4+ messages in thread
From: Andreas Bießmann @ 2013-01-23 11:28 UTC (permalink / raw)
  To: u-boot

On 23.01.2013 00:51, Andreas Bie?mann wrote:
> ps on BSD hosts (like OS X) do not provide the --no-headers switch nor
> understand the AIX format descriptions. Make the call for ps portable and filter
> the relevant line from output (including the header) with sed.
> Also switch from pgrep to ps to get the list of children and use the same
> mechanism as for pgid.
> 
> This patch makes the MAKEALL script cleanly stoppable on bare OS X when using
> the parallel builds of targets.
> 
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> ---
>  MAKEALL | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/MAKEALL b/MAKEALL
> index 5b06c54..d926846 100755
> --- a/MAKEALL
> +++ b/MAKEALL
> @@ -784,8 +784,8 @@ 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 pgid=`ps -p $$ -o pgid | sed -e "/PGID/d"`
> +	local children=`ps -g $pgid -o pid | sed -e "/PID\|$$\|$pgid/d"`

Oumpf, just realized that the 'ps -g' is _not_ portable though. The
linux variant selects by session OR group name while the BSD variant
uses the process group.
I'm looking for a better solution which is portable.

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2] MAKEALL: fix kill_children for BSD hosts
  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
  2013-02-08 20:52   ` Joe Hershberger
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Bießmann @ 2013-02-08  8:35 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2] MAKEALL: fix kill_children for BSD hosts
  2013-02-08  8:35 ` [U-Boot] [PATCH v2] " Andreas Bießmann
@ 2013-02-08 20:52   ` Joe Hershberger
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Hershberger @ 2013-02-08 20:52 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 8, 2013 at 2:35 AM, Andreas Bie?mann
<andreas.devel@googlemail.com> wrote:
> 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>
> ---

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-08 20:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [U-Boot] [PATCH v2] " Andreas Bießmann
2013-02-08 20:52   ` Joe Hershberger

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.