Bound all external process calls with a timeout and forced termination

Ouverte
#255 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
java

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

Langage dominant
Java
Étoiles
6
Forks
6
Merge moyen
10 h 11 min
PR mergées (30 j)
12

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de JDiskMark/jdm-java

Toutes les issues de JDiskMark/jdm-java

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.