我正在执行以下命令来杀死一个进程,但它没有杀死任何进程。
我试过的命令:#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);
}
}
}
请帮助解决这个问题。