fix(windows): daemon stop/kill now uses proper Windows API (GH#992)

On Windows, the daemon stop command was failing with "exit status 1" because
`taskkill` without `/F` flag does not work for console processes that do not
have windows to receive close messages.

Changes:
- Use `os.Process.Kill()` which calls Windows `TerminateProcess` API
- This is the reliable way to terminate processes on Windows
- The graceful RPC shutdown is already attempted before falling back to kill
- Updated error messages to be platform-agnostic (removed SIGTERM/SIGKILL)

The fix uses Go cross-platform process APIs instead of shelling out to
external commands, which is more reliable and portable.

Closes #992

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
fang
2026-01-09 23:04:40 -08:00
committed by Steve Yegge
parent ee34003f02
commit ecde3f2fd1
2 changed files with 50 additions and 25 deletions

View File

@@ -411,9 +411,9 @@ func stopDaemonWithTimeout(daemon DaemonInfo) error {
}
}
// Try SIGTERM with 3 second timeout
// Try graceful kill with 3 second timeout
if err := killProcess(daemon.PID); err != nil {
return fmt.Errorf("SIGTERM failed: %w", err)
return fmt.Errorf("kill process failed: %w", err)
}
// Wait up to 3 seconds for process to die
@@ -424,9 +424,9 @@ func stopDaemonWithTimeout(daemon DaemonInfo) error {
}
}
// SIGTERM timeout, try SIGKILL with 1 second timeout
// Graceful kill timeout, try force kill with 1 second timeout
if err := forceKillProcess(daemon.PID); err != nil {
return fmt.Errorf("SIGKILL failed: %w", err)
return fmt.Errorf("force kill failed: %w", err)
}
// Wait up to 1 second for process to die
@@ -437,5 +437,5 @@ func stopDaemonWithTimeout(daemon DaemonInfo) error {
}
}
return fmt.Errorf("process %d did not die after SIGKILL", daemon.PID)
return fmt.Errorf("process %d did not die after force kill", daemon.PID)
}