我正在执行以下命令来杀死进程,但它不会杀死任何进程。
命令我试过:#kill -9“2319”
但同时我在命令提示符下执行相同的命令时工作正常。
private void killProcess()
{
InputStream errorStream = null;
final String taskKill = isWindows() ? InstallerConstants.WIN_TASKKILL : InstallerConstants.LIN_TASKKILL;
try
{
Process process = null;
final String killCMD = taskKill+"\""+getGuiProcess()+"\"";\\kill -9 "2319"
process = runTime.exec(killCMD);
errorStream = process.getErrorStream();
bufferedReader = new BufferedReader(new InputStreamReader(errorStream));
String error = "";
while(bufferedReader.readLine() != null)
{
error = bufferedReader.readLine();
}
if(!(error==null || "".equals(error)))
{
logger.error(error);
}
}
catch (IOException ioException) {
logger.error(ioException.getMessage(), ioException);
}
finally
{
try
{
if(bufferedReader!=null)
{
bufferedReader.close();
}
if(errorStream!=null)
{
errorStream.close();
}
}
catch (IOException ioException) {
logger.error(ioException.getMessage(), ioException);
}
}
}
请帮助克服这个问题。
答案 0 :(得分:0)
您需要指定kill命令的绝对路径
/bin/kill may be?
$ whereis kill //output will show you where kill command is.
你得到任何错误吗?