emrg: stop_all cmdline-scan fallback for missed python daemon (Windows installer DeleteFile code 5) - #826
Conversation
…s installer DeleteFile code 5)
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 589 (1/3). Re-verified head d7f3085: 4 files +176/−2 — _scan_windows_python_emrg helper (CIM scan, -m emrg incl. emrg.server, own-pid excluded, {{ }} escaped, errors → []), stop_daemon cmdline fallback after pid path, _verify_windows python-residual check; order unchanged. Full pytest 884 passed + 1 skipped (885 collected, Agent.md synced), import + CLI green; CI test + test-windows PASS (32013795087).
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 590 (2/3). Re-verified head d7f3085 unchanged (4 files +176/−2): _scan_windows_python_emrg correctly matches both TUI (-m emrg) and daemon (-m emrg.server) via substring, excludes own pid, swallows errors → []; stop_daemon() falls back to cmdline scan after the pid-file path (the emrgd.pid blind spot — #593 family); _verify_windows reports named python-emrg residuals → exit 1 so the installer never overwrites locked files silently. Order GUI→TUI→daemon→bundled-git→verify unchanged. CI test + test-windows PASS (32013795087), mergeable CLEAN.
|
I tested the #826 cmdline-scan fallback on the merged master and found one non-blocking gap worth closing. Verification this cycle: Finding — the PowerShell name filter does not match versioned Python launchers: I checked the pattern against real Windows image names:
Suggest widening the name pattern, e.g. Not blocking — the common packaged path uses |
Fixes host rant 2026-08-17T17:03:38 — Windows installer still fails with
DeleteFile failed; code 5onwebsockets\...\speedups.cp313-win_amd64.pydbecause a live python process holding the C extension survivedemrg stop.Root cause (three pid-file blind spots in
emrg/_stop_all.py)stop_daemon()only killed the pid stored in~/.emrg/emrgd.pid— when the pid file is missing/stale/mismatched (GUI spawn, crash restart, external unlink — the emrg: port-file self-heal + G43 PID guard — kill the zombie-daemon state #593 family), the actually-live daemon (pythonw.exe -m emrg.server) was missed.stop_tui()deliberately excludesemrg.server— so even a daemon missed by step 1 is never touched here either.verify()only checked EMRG.exe + emrgd.pid + bundled git — a missed kill went unreported, exit 0, and Inno overwroteinstall\onto locked files.Fix (Windows cmdline scan — command line is the only reliable identity)
_scan_windows_python_emrg(own_pid): CIM scan forpython.exe|pythonw.exewhose CommandLine matches-m emrg(includes-m emrg.server), excludes the invoking pid. PowerShell template braces escaped{{ }}(same contract asstop_tui()); errors/timeouts degrade to[].stop_daemon(): after the pid-file path, append the cmdline scan fallback — kills every remaining emrg python process (returns[]on POSIX, behavior unchanged there)._verify_windows(): adds the cmdline scan — any surviving python emrg process (even with no pid file) is reported as a named residual → exit 1 → installer aborts and shows the log instead of overwriting locked files.Verification (self-verifiable)
_scan_windows_python_emrgparses CIM pid output, renders template without ValueError, POSIX →[], subprocess failure →[](4 tests).stop_daemon()kills pid 777 from cmdline scan when the pid file is missing; no scan → no kill (2 tests)._verify_windows()reportspython emrg process (pid 555)residual; clean when scan empty (2 tests).stop_daemon+_verify_windowsand asserts the scan does NOT excludeemrg.server(1 test).