Stabilize browser smoke profile cleanup

This commit is contained in:
cnc
2026-06-02 06:47:02 +08:00
parent 87fcf74135
commit fbe1c31961

View File

@@ -189,6 +189,16 @@ virtual_time_budget=${BROWSER_SMOKE_VIRTUAL_TIME_BUDGET:-20000}
server_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_browser_smoke_server.XXXXXX.log")
dom_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_browser_smoke_dom.XXXXXX.html")
profile_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_browser_smoke_profile.XXXXXX")
remove_profile_dir() {
local attempt
for attempt in {1..20}; do
if rm -rf "$profile_dir"; then
return 0
fi
sleep 0.1
done
rm -rf "$profile_dir" >/dev/null 2>&1 || true
}
cleanup() {
if [[ -n "${chromium_pid:-}" ]]; then
kill "$chromium_pid" >/dev/null 2>&1 || true
@@ -199,7 +209,7 @@ cleanup() {
wait "$server_pid" >/dev/null 2>&1 || true
fi
rm -f "$server_log" "$dom_log"
rm -rf "$profile_dir"
remove_profile_dir
}
trap cleanup EXIT