未验证 提交 4a1303b6 编写于 作者: W wenjun 提交者: GitHub

[Improvement][Worker] Kill task error(#5199) (#5212)

上级 97fb08f0
...@@ -409,7 +409,7 @@ public class ProcessUtils { ...@@ -409,7 +409,7 @@ public class ProcessUtils {
* @throws Exception exception * @throws Exception exception
*/ */
public static String getPidsStr(int processId) throws Exception { public static String getPidsStr(int processId) throws Exception {
StringBuilder sb = new StringBuilder(); List<String> pidList = new ArrayList<>();
Matcher mat = null; Matcher mat = null;
// pstree pid get sub pids // pstree pid get sub pids
if (OSUtils.isMacOS()) { if (OSUtils.isMacOS()) {
...@@ -424,11 +424,14 @@ public class ProcessUtils { ...@@ -424,11 +424,14 @@ public class ProcessUtils {
if (null != mat) { if (null != mat) {
while (mat.find()) { while (mat.find()) {
sb.append(mat.group(1)).append(" "); pidList.add(mat.group(1));
} }
} }
return sb.toString().trim(); if (CommonUtils.isSudoEnable() && !pidList.isEmpty()) {
pidList = pidList.subList(1, pidList.size());
}
return String.join(" ", pidList).trim();
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册