HADOOP-13467. Shell#getSignalKillCommand should use the bash builtin on Linux. (Arpit Agarwal)
This commit is contained in:
parent
4a8e6dc02f
commit
b8ca84ac99
@ -311,11 +311,16 @@ public static String[] getSignalKillCommand(int code, String pid) {
|
||||
}
|
||||
}
|
||||
|
||||
// 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 };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,9 +235,11 @@ public void testGetCheckProcessIsAliveCommand() throws Exception {
|
||||
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 void testGetSignalKillCommand() throws Exception {
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user