From patchwork Fri Feb 8 08:35:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 219067 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4688B2C0080 for ; Fri, 8 Feb 2013 19:36:22 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C35BA4A0A9; Fri, 8 Feb 2013 09:36:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bMjx0cBqpwDy; Fri, 8 Feb 2013 09:36:20 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 66EB54A0B6; Fri, 8 Feb 2013 09:36:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A69534A0B6 for ; Fri, 8 Feb 2013 09:36:17 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cNbAYCY+PgNX for ; Fri, 8 Feb 2013 09:36:16 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by theia.denx.de (Postfix) with ESMTPS id A07564A0A9 for ; Fri, 8 Feb 2013 09:36:15 +0100 (CET) Received: by mail-bk0-f50.google.com with SMTP id jg9so1571816bkc.37 for ; Fri, 08 Feb 2013 00:36:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=yMYUIpslRnDHB78+Y8pApdxJL8siAzTJqEXbJhYjqW4=; b=nrs9zmEoBDFjo6Vs2iYYyqT00da2M+xZiY5YG9XLumF1OgkRVdqKpUpE9w1xr1tsCh PM7wuF/qqMRQNvo5SLIjailvNEvCpsMwDuC0f/BLV7U5NZ/Lxi7X3AbzjlxCvCiJOy71 CjRzY/RbI0WLxOT4DSLmsIbdQc43RU9xO87geoO0CBHrHmbPWE5t01AyClbsYk6ORIUP TBG+2/e40ULDCYNusT3IYbcKHIb9fsKEncQP3t588PODt6d0DSQcrrPMy2KYuhSz2hTd +XAAL+iz0O2WzwyaW79hticTmIuDW9XxXDRJpVBhfWmi8R6kdI8RYUBIeK/YGBtWLdAY 3Pjg== X-Received: by 10.204.4.71 with SMTP id 7mr1198747bkq.73.1360312573550; Fri, 08 Feb 2013 00:36:13 -0800 (PST) Received: from localhost ([2a01:198:47b:1:210:75ff:fe1a:cd1e]) by mx.google.com with ESMTPS id x10sm9846771bkv.13.2013.02.08.00.36.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 08 Feb 2013 00:36:12 -0800 (PST) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: U-Boot ML Date: Fri, 8 Feb 2013 08:35:57 +0000 Message-Id: <1360312557-25604-1-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1358898669-21682-1-git-send-email-andreas.devel@googlemail.com> References: <1358898669-21682-1-git-send-email-andreas.devel@googlemail.com> MIME-Version: 1.0 Cc: Joe Hershberger Subject: [U-Boot] [PATCH v2] MAKEALL: fix kill_children for BSD hosts X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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(-) 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