Bound all external process calls with a timeout and forced termination

Đang mở
#255 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
operating-systems

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).

Ngôn ngữ chính
Java
Star
6
Fork
6
Merge trung bình
10 giờ 11 phút
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JDiskMark/jdm-java

Tất cả issue của JDiskMark/jdm-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.