|
@@ -409,7 +409,7 @@ public class ProcessUtils {
|
|
|
* @throws Exception exception
|
|
|
*/
|
|
|
public static String getPidsStr(int processId) throws Exception {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
+ List<String> pidList = new ArrayList<>();
|
|
|
Matcher mat = null;
|
|
|
|
|
|
if (OSUtils.isMacOS()) {
|
|
@@ -424,11 +424,14 @@ public class ProcessUtils {
|
|
|
|
|
|
if (null != mat) {
|
|
|
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();
|
|
|
}
|
|
|
|
|
|
|