Skip to content

Commit 64b7358

Browse files
committed
ci cleanup use status-based lsof timeout handling
1 parent 3395d11 commit 64b7358

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

scripts/ci/cleanup-dmg.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,13 @@ kill_mount_holders() {
344344
if [ "${lsof_timeout_tool}" = "gtimeout" ] || [ "${lsof_timeout_tool}" = "timeout" ]; then
345345
local lsof_output=""
346346
local lsof_status=0
347-
local started_at=0
348-
local ended_at=0
349-
local elapsed=0
350-
started_at="$(date +%s 2>/dev/null || echo 0)"
351347
lsof_output="$("${lsof_timeout_tool}" "${lsof_timeout_seconds}" lsof -t +D "${mount_point}" 2>/dev/null)" || lsof_status=$?
352-
ended_at="$(date +%s 2>/dev/null || echo 0)"
353-
if [ "${started_at}" -gt 0 ] && [ "${ended_at}" -ge "${started_at}" ]; then
354-
elapsed=$((ended_at - started_at))
355-
fi
356-
if [ "${lsof_status}" -ne 0 ] && [ "${elapsed}" -ge "${lsof_timeout_seconds}" ]; then
348+
if [ "${lsof_status}" -eq 124 ]; then
357349
echo "WARN: lsof timed out while scanning ${mount_point}; skip mount-holder cleanup." >&2
358350
return 0
359351
fi
360352
if [ "${lsof_status}" -ne 0 ] && [ -z "${lsof_output}" ]; then
353+
echo "WARN: lsof failed while scanning ${mount_point} (tool=${lsof_timeout_tool}, exit=${lsof_status}); skip mount-holder cleanup." >&2
361354
return 0
362355
fi
363356
holder_pids="$(printf '%s\n' "${lsof_output}" | awk 'NF' | sort -u)"
@@ -394,6 +387,7 @@ PY
394387
return 0
395388
fi
396389
if [ "${lsof_status}" -ne 0 ] && [ -z "${lsof_output}" ]; then
390+
echo "WARN: lsof failed while scanning ${mount_point} (tool=python3, exit=${lsof_status}); skip mount-holder cleanup." >&2
397391
return 0
398392
fi
399393
holder_pids="$(printf '%s\n' "${lsof_output}" | awk 'NF' | sort -u)"

0 commit comments

Comments
 (0)