Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 153A1200B5A for ; Thu, 4 Aug 2016 19:32:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 13ADE160A6A; Thu, 4 Aug 2016 17:32:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 63F35160AB0 for ; Thu, 4 Aug 2016 19:32:47 +0200 (CEST) Received: (qmail 3487 invoked by uid 500); 4 Aug 2016 17:32:46 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 3245 invoked by uid 99); 4 Aug 2016 17:32:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2016 17:32:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AD40DE0B40; Thu, 4 Aug 2016 17:32:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: arp@apache.org To: common-commits@hadoop.apache.org Date: Thu, 04 Aug 2016 17:32:46 -0000 Message-Id: <7002e03b7d614d8bb9f096f908e6086f@git.apache.org> In-Reply-To: <2566823d19b5437e8d5bd1de7c51042d@git.apache.org> References: <2566823d19b5437e8d5bd1de7c51042d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] hadoop git commit: HADOOP-13467. Shell#getSignalKillCommand should use the bash builtin on Linux. (Arpit Agarwal) archived-at: Thu, 04 Aug 2016 17:32:48 -0000 HADOOP-13467. Shell#getSignalKillCommand should use the bash builtin on Linux. (Arpit Agarwal) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/365a2709 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/365a2709 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/365a2709 Branch: refs/heads/branch-2 Commit: 365a27099c5f2ea273368df7e899650d10fc5c99 Parents: 3b2554f Author: Arpit Agarwal Authored: Thu Aug 4 10:07:53 2016 -0700 Committer: Arpit Agarwal Committed: Thu Aug 4 10:08:23 2016 -0700 ---------------------------------------------------------------------- .../src/main/java/org/apache/hadoop/util/Shell.java | 11 ++++++++--- .../src/test/java/org/apache/hadoop/util/TestShell.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/365a2709/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java index 3007d32..0311a1e 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java @@ -311,11 +311,16 @@ public abstract class Shell { } } + // Use the bash-builtin instead of the Unix kill command (usually + // /bin/kill) as the bash-builtin supports "--" in all Hadoop supported + // OSes. + final String quotedPid = bashQuote(pid); if (isSetsidAvailable) { - // Use the shell-builtin as it support "--" in all Hadoop supported OSes - return new String[] {"kill", "-" + code, "--", "-" + pid}; + return new String[] { "bash", "-c", "kill -" + code + " -- -" + + quotedPid }; } else { - return new String[] {"kill", "-" + code, pid }; + return new String[] { "bash", "-c", "kill -" + code + " " + + quotedPid }; } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/365a2709/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java index c0491fac..3ef6fb1 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestShell.java @@ -240,9 +240,11 @@ public class TestShell extends Assert { expectedCommand = new String[]{getWinUtilsPath(), "task", "isAlive", anyPid }; } else if (Shell.isSetsidAvailable) { - expectedCommand = new String[] {"kill", "-0", "--", "-" + anyPid }; + expectedCommand = new String[] { "bash", "-c", "kill -0 -- -'" + + anyPid + "'"}; } else { - expectedCommand = new String[] {"kill", "-0", anyPid }; + expectedCommand = new String[] {"bash", "-c", "kill -0 '" + anyPid + + "'" }; } Assert.assertArrayEquals(expectedCommand, checkProcessAliveCommand); } @@ -260,9 +262,11 @@ public class TestShell extends Assert { expectedCommand = new String[]{getWinUtilsPath(), "task", "kill", anyPid }; } else if (Shell.isSetsidAvailable) { - expectedCommand = new String[] {"kill", "-9", "--", "-" + anyPid }; + expectedCommand = new String[] { "bash", "-c", "kill -9 -- -'" + anyPid + + "'"}; } else { - expectedCommand = new String[] {"kill", "-9", anyPid }; + expectedCommand = new String[]{ "bash", "-c", "kill -9 '" + anyPid + + "'"}; } Assert.assertArrayEquals(expectedCommand, checkProcessAliveCommand); } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org