kill frozen external binaries

This commit is contained in:
carlospolop 2025-05-18 01:20:32 +02:00
parent 4c16f72ae2
commit 63c090059b

View File

@ -31,14 +31,17 @@ execBin() {
# ---------------- 120second wallclock timeout ----------------
if command -v timeout >/dev/null 2>&1; then # GNU/BSD timeout
print_info "Running $TOOL_NAME with 120s timeout"
timeout --preserve-status 120 "$TMP_BIN" $PARAMS
elif command -v gtimeout >/dev/null 2>&1; then # Homebrew coreutils (macOS)
print_info "Running $TOOL_NAME with 120s gtimeout"
gtimeout --preserve-status 120 "$TMP_BIN" $PARAMS
else # POSIX fallback
print_info "Running $TOOL_NAME with 120s custom timeout"
(
"$TMP_BIN" $PARAMS & # run in background
cmdpid=$!
( sleep 120 && kill -0 "$cmdpid" 2>/dev/null && kill -TERM "$cmdpid" ) &
( sleep 120 && kill -9 "$cmdpid" 2>/dev/null) &
watcher=$!
wait "$cmdpid"
rc=$?