Bound all external process calls with a timeout and forced termination

未关闭
#255 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
java

调研方向

Start with UtilsLinuxOs.getWholeDisks, which already uses the CompletableFuture drain, waitFor(timeout) and destroyForcibly pattern, and compare it with the unbounded calls in UtilsLinuxOs.getPartitionFromFilePath, UtilsMacOs and UtilOs.runPowerShellOneLiner. Before writing code, settle where the shared runCommand helper should live, since the issue leaves that open. Done means every ProcessBuilder call site is bounded and force-destroyed on timeout, returns null or an empty list, and logs a warning.

由索引模型根据 Issue 内容生成。

描述

enhancement linux macos windows

Background

PR #254 (#252) added proper timeouts to the USB VID/PID lookups on Windows
(UtilsWinOs.getUsbIds, 15 s) and macOS (UtilsMacOs.runCommandLines, 10 s):
output is drained asynchronously, waitFor(timeout) is honoured, and the child
is destroyForcibly()'d on expiry. Review feedback (Copilot) flagged that the
remaining process calls do not follow this pattern.

Problem

Many ProcessBuilder call sites either:

  • call process.waitFor() with no timeout, or
  • read stdout to EOF with readLine() before calling waitFor(n, SECONDS),
    making the timeout ineffective, and never destroy the child.

A hung child (stale network mount for df, stalled DiskArbitration for
diskutil, slow/broken WMI for PowerShell) can block drive detection,
benchmark setup, or the UI indefinitely.

Affected call sites (non-exhaustive)

  • UtilsLinuxOs.getPartitionFromFilePath (df -k), waitFor() without a timeout
  • UtilsLinuxOs.getDeviceNamesFromPartition (lsblk -no pkname), waitFor() without a timeout
  • UtilsMacOs: df -k, diskutil info (lines ~92, ~153), system_profiler,
    the generic command runner (~208), mount (~318)
  • UtilOs: remaining waitFor() calls with no timeout (Linux SMART/lsblk/udevadm helpers) and
    read-then-waitFor(n) PowerShell helpers (e.g. runPowerShellOneLiner)

Proposed approach

  • Use the existing pattern from UtilsLinuxOs.getWholeDisks:
    CompletableFuture output drain → waitFor(timeout) → destroyForcibly() in finally.
  • Consider one shared helper (e.g. runCommand(timeout, String... cmd) → List<String>)
    so call sites stay consistent. Confirm package/location before adding.
  • Timeouts: 10 s for native tools, 15 s for PowerShell (start-up + WMI).
  • On timeout: log at WARNING and return the existing "unavailable" value
    (null/empty list) so detection failures never block a benchmark.

Priority

Low–medium. Hangs are rare on Linux (sysfs/statfs), more plausible on macOS
(diskutil) and Windows (PowerShell/WMI).

主要语言
Java
星标
6
派生
6
平均合并
10 小时 11 分钟
30 天内合并 PR
12

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JDiskMark/jdm-java 的其他 Issue

查看 JDiskMark/jdm-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。