Commit 5f9e827
fix(installer): kill orphan testgen + postgres before install/delete
A previous standalone session that exited dirty (force-killed via Task
Manager, browser tab close, etc.) leaves the embedded postgres alive —
it was spawned with CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW, so it
survives its parent. `tg install` then fails at standalone-setup because
the orphan still owns ~/.testgen/pgdata; `tg delete` half-finishes
because Windows file-locks the running testgen.exe binary, blocking
`uv tool uninstall` from removing it.
Add a `stop_standalone_orphans()` helper that:
- reads ~/.testgen/pgdata/postmaster.pid → kills that specific PID
(so a user's unrelated postgres installs are untouched),
- then force-kills testgen.exe by image name (safe — installer is
dk-installer.exe; no self-kill risk).
Called from `_delete_pip` before `uv tool uninstall`, and from
`TestgenStandaloneSetupStep.pre_execute` — which only runs after
`_resolve_install_mode` has confirmed no install marker, so the
existing "you already have an install, use upgrade or delete"
invariant is preserved.
Best-effort: silent on a clean machine, never raises (outer try/except
guards against transient filesystem/permission glitches).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c4b1e70 commit 5f9e827
1 file changed
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2508 | 2508 | | |
2509 | 2509 | | |
2510 | 2510 | | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
2511 | 2576 | | |
2512 | 2577 | | |
2513 | 2578 | | |
| |||
2624 | 2689 | | |
2625 | 2690 | | |
2626 | 2691 | | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
2627 | 2696 | | |
2628 | 2697 | | |
2629 | 2698 | | |
| |||
3102 | 3171 | | |
3103 | 3172 | | |
3104 | 3173 | | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
3105 | 3181 | | |
3106 | 3182 | | |
3107 | 3183 | | |
| |||
0 commit comments