Files
hermes-agent/hermes_cli
teknium1 d809057a12 fix(gateway): guard Windows post-drain taskkill with the pre-drain start time
_force_terminate_known_gateway_pids read get_process_start_time(pid) at
kill time and handed it to terminate_pid as expected_start_time — a
comparison of the process with itself that can never fail. After the
new <=30 s planned-stop drain in stop_profile_gateway, a gateway that
exited mid-wait and had its PID recycled would be taskkill'd /T /F
anyway (the exact svchost.exe hazard the guard exists for, #89614).

Capture the fingerprint before waiting, as _escalate_wedged_gateway
already does, and make _force_terminate_known_gateway_pids take a
{pid: start_time} mapping so no caller can re-read at kill time.
stop()/restart() fingerprint their collected PIDs at collection.

Test: recycled PID (start 100 -> 999 after the drain deadline) now
reaches terminate_pid with expected_start_time=100, so its mismatch
refusal fires; red before this change ((4242, True, 999)).
2026-09-16 16:52:59 -07:00
..
…