Bound all external process calls with a timeout and forced termination

Abierto
#255 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Java
Estrellas
6
Forks
6
Merge medio
10 h 11 min
PR fusionados (30 d)
12

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de JDiskMark/jdm-java

Todos los issues de JDiskMark/jdm-java

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.