github-advanced-security[bot] commented on code in PR #17005:
URL: 
https://github.com/apache/dolphinscheduler/pull/17005#discussion_r1963703621


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -216,13 +216,15 @@
             return;
         }
 
-        // soft kill
-        log.info("Begin to kill process process, pid is : {}", 
taskRequest.getProcessId());
-        process.destroy();
-        if (!process.waitFor(5, TimeUnit.SECONDS)) {
-            process.destroyForcibly();
+        // Try to kill process tree
+        boolean killed = ProcessUtils.kill(taskRequest);
+        if (killed) {
+            log.info("Process tree for task: {} is killed or already finished, 
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/5151)



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -216,13 +216,15 @@
             return;
         }
 
-        // soft kill
-        log.info("Begin to kill process process, pid is : {}", 
taskRequest.getProcessId());
-        process.destroy();
-        if (!process.waitFor(5, TimeUnit.SECONDS)) {
-            process.destroyForcibly();
+        // Try to kill process tree
+        boolean killed = ProcessUtils.kill(taskRequest);
+        if (killed) {
+            log.info("Process tree for task: {} is killed or already finished, 
pid: {}",
+                    taskRequest.getTaskAppId(), taskRequest.getProcessId());
+        } else {
+            log.error("Failed to kill 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/5152)



-- 
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]

Reply via email to