Cleanup trap

This commit is contained in:
Matthew Knight 2026-03-05 23:48:42 -08:00
parent edff8885f0
commit b5bbe3acae
No known key found for this signature in database
1 changed files with 14 additions and 7 deletions

View File

@ -81,6 +81,17 @@ runs:
TOTAL_CRASHES=0 TOTAL_CRASHES=0
TARGET_NUM=0 TARGET_NUM=0
ACTIVE_RUN_ID=""
# Single EXIT trap that finishes whatever run is active.
cleanup() {
if [ -n "${ACTIVE_RUN_ID}" ]; then
echo "Finishing run ${ACTIVE_RUN_ID} (cleanup)..."
cairn run finish -server "${CAIRN_SERVER}" -id "${ACTIVE_RUN_ID}" || true
ACTIVE_RUN_ID=""
fi
}
trap cleanup EXIT
# ── Iterate over each target name ── # ── Iterate over each target name ──
while IFS= read -r FUZZ_TARGET; do while IFS= read -r FUZZ_TARGET; do
@ -109,13 +120,9 @@ runs:
-server "${CAIRN_SERVER}" \ -server "${CAIRN_SERVER}" \
-target-id "${CAIRN_TARGET_ID}" \ -target-id "${CAIRN_TARGET_ID}" \
-commit "${COMMIT}") -commit "${COMMIT}")
ACTIVE_RUN_ID="${RUN_ID}"
echo "Run ID: ${RUN_ID}" echo "Run ID: ${RUN_ID}"
finish_run() {
cairn run finish -server "${CAIRN_SERVER}" -id "${RUN_ID}" || true
}
trap finish_run EXIT
# ── Download existing corpus ── # ── Download existing corpus ──
SEEDS="afl-seeds-${TARGET_NUM}" SEEDS="afl-seeds-${TARGET_NUM}"
rm -rf "${SEEDS}" rm -rf "${SEEDS}"
@ -230,8 +237,8 @@ runs:
fi fi
# ── Finish run ── # ── Finish run ──
finish_run cairn run finish -server "${CAIRN_SERVER}" -id "${RUN_ID}" || true
trap - EXIT ACTIVE_RUN_ID=""
done <<EOF done <<EOF
${TARGETS} ${TARGETS}