hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject [29/50] [abbrv] hadoop git commit: HADOOP-13467. Shell#getSignalKillCommand should use the bash builtin on Linux. (Arpit Agarwal)
Date Fri, 05 Aug 2016 20:44:30 GMT
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/b8ca84ac
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b8ca84ac
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b8ca84ac

Branch: refs/heads/YARN-2915
Commit: b8ca84ac99d2cb2bfe43930eb9b178ee010e4812
Parents: 4a8e6dc
Author: Arpit Agarwal <arp@apache.org>
Authored: Thu Aug 4 10:07:53 2016 -0700
Committer: Arpit Agarwal <arp@apache.org>
Committed: Thu Aug 4 10:07:53 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/b8ca84ac/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 60f8ff5..7149268 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/b8ca84ac/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 acc7f1d..67903f7 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
@@ -235,9 +235,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);
   }
@@ -255,9 +257,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


Mime
View raw message