github-advanced-security[bot] commented on code in PR #17005:
URL:
https://github.com/apache/dolphinscheduler/pull/17005#discussion_r1947543340
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -216,13 +216,30 @@
return;
}
- // soft kill
- log.info("Begin to kill process process, pid is : {}",
taskRequest.getProcessId());
- process.destroy();
- if (!process.waitFor(5, TimeUnit.SECONDS)) {
+ try {
+ // Try to kill process tree first
+ boolean killed = ProcessUtils.kill(taskRequest);
+ if (killed) {
+ log.info("Successfully killed process tree for task: {}, pid:
{}",
+ taskRequest.getTaskAppId(),
taskRequest.getProcessId());
Review Comment:
## Deprecated method or constructor invocation
Invoking [TaskExecutionContext.getTaskAppId](1) should be avoided because it
has been deprecated.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5149)
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -216,13 +216,30 @@
return;
}
- // soft kill
- log.info("Begin to kill process process, pid is : {}",
taskRequest.getProcessId());
- process.destroy();
- if (!process.waitFor(5, TimeUnit.SECONDS)) {
+ try {
+ // Try to kill process tree first
+ boolean killed = ProcessUtils.kill(taskRequest);
+ if (killed) {
+ log.info("Successfully killed process tree for task: {}, pid:
{}",
+ taskRequest.getTaskAppId(),
taskRequest.getProcessId());
+ return;
+ }
+
+ // If killing process tree fails, try to destroy the process
directly
+ log.info("Failed to kill process tree, trying to destroy process
directly");
+ process.destroy();
+ if (!process.waitFor(5, TimeUnit.SECONDS)) {
+ log.info("Process did not exit after destroy, forcing
termination");
+ process.destroyForcibly();
+ }
+ log.info("Successfully killed process tree for task: {}, pid: {}",
+ taskRequest.getTaskAppId(), taskRequest.getProcessId());
Review Comment:
## Deprecated method or constructor invocation
Invoking [TaskExecutionContext.getTaskAppId](1) should be avoided because it
has been deprecated.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/5150)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]