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