[agent][executor]- bug - 2
This commit is contained in:
@@ -132,6 +132,7 @@ public class CommandExecutor {
|
||||
// get the command result must also be a timeout smaller than the process
|
||||
int waitFor = process.waitFor();
|
||||
|
||||
|
||||
// get the process result
|
||||
if (ObjectUtils.isNotEmpty(waitFor) && ObjectUtils.isNotEmpty(process.info())) {
|
||||
|
||||
@@ -139,15 +140,15 @@ public class CommandExecutor {
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
|
||||
// 设置 命令执行退出返回值
|
||||
processResult = process.exitValue();
|
||||
|
||||
log.debug(
|
||||
"current shell command {} result is {}",
|
||||
processBuilder.command(),
|
||||
processResult
|
||||
);
|
||||
|
||||
// 设置 命令执行退出返回值
|
||||
processResult = process.exitValue();
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
log.error(
|
||||
"Shell command error ! {} + {}",
|
||||
@@ -200,10 +201,16 @@ public class CommandExecutor {
|
||||
|
||||
|
||||
// 命令没有正确的处理完成,需要手动关停程序
|
||||
// 只有当该进程还存活,执行关闭操作
|
||||
// 只有当该进程还存活,执行关闭操作, 没有返回结果的命令如 ping baidu.com 只有在线程关闭之后才可以有结果s
|
||||
if (process.isAlive()) {
|
||||
// shutdown the process
|
||||
log.debug("开始销毁命令执行进程!");
|
||||
log.debug(
|
||||
"开始销毁命令[ {} ]执行进程!",
|
||||
process
|
||||
.info()
|
||||
.commandLine()
|
||||
.get()
|
||||
);
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user