class ProcessUtils {

  public static String getPidsStr(int processId) throws Exception {
    StringBuilder sb = new StringBuilder();
    Matcher mat;
    // pstree pid get sub pids
    if (OSUtils.isMacOS()) {
      String pids = OSUtils.exeCmd("pstree -sp " + processId);
      mat = MACPATTERN.matcher(pids);
    } else {
      String pids = OSUtils.exeCmd("pstree -p " + processId);
      mat = WINDOWSATTERN.matcher(pids);
    }

    while (mat.find()) {
      sb.append(mat.group(1)).append(" ");
    }
    return sb.toString().trim();
  }

}