Files
gastown/internal/daemon/proc_windows.go
mayor 45ffac6e92 fix(daemon): cross-platform build for Dolt server management
Extract platform-specific syscall code into proc_unix.go and proc_windows.go
with appropriate build tags. This fixes TestCrossPlatformBuild which failed
because syscall.SysProcAttr.Setpgid is Unix-only.

Changes:
- setSysProcAttr(): Sets process group on Unix, no-op on Windows
- isProcessAlive(): Uses Signal(0) on Unix, nil signal on Windows
- sendTermSignal(): SIGTERM on Unix, Kill() on Windows
- sendKillSignal(): SIGKILL on Unix, Kill() on Windows

Fixes gt-3078ed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 18:29:35 -08:00

39 lines
1.1 KiB
Go

//go:build windows
package daemon
import (
"os"
"os/exec"
)
// setSysProcAttr sets platform-specific process attributes.
// On Windows, no special attributes needed for process group detachment.
func setSysProcAttr(cmd *exec.Cmd) {
// No-op on Windows - process will run independently
}
// isProcessAlive checks if a process is still running.
// On Windows, we try to open the process with minimal access.
func isProcessAlive(p *os.Process) bool {
// On Windows, FindProcess always succeeds, and Signal(0) may not work.
// The best we can do is try to signal and see if it fails.
// A killed process will return an error.
err := p.Signal(os.Signal(nil))
// If err is nil or "not supported", process may still be alive
// If err mentions "finished" or similar, process is dead
return err == nil
}
// sendTermSignal sends a termination signal.
// On Windows, there's no SIGTERM - we use Kill() directly.
func sendTermSignal(p *os.Process) error {
return p.Kill()
}
// sendKillSignal sends a kill signal.
// On Windows, Kill() is the only option.
func sendKillSignal(p *os.Process) error {
return p.Kill()
}