cli/pkg/php/services_windows.go
Snider 92373db6ac
fix: add Windows compatibility for process management (#58)
Add build tags to separate Unix and Windows process handling in pkg/php:

- services_unix.go: Unix-specific process group handling (Setpgid, Getpgid, Kill)
- services_windows.go: Windows-compatible alternatives using os.Signal
- services.go: Use platform-agnostic helper functions

The pkg/php package now compiles on Windows. Process termination works
via os.Interrupt/os.Kill instead of Unix signals.

Fixes #56

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 01:56:44 +00:00

34 lines
756 B
Go

//go:build windows
package php
import (
"os"
"os/exec"
)
// setSysProcAttr sets Windows-specific process attributes.
// Windows doesn't support Setpgid, so this is a no-op.
func setSysProcAttr(cmd *exec.Cmd) {
// No-op on Windows - process groups work differently
}
// signalProcessGroup sends a termination signal to the process.
// On Windows, we can only signal the main process, not a group.
func signalProcessGroup(cmd *exec.Cmd, sig os.Signal) error {
if cmd.Process == nil {
return nil
}
return cmd.Process.Signal(sig)
}
// termSignal returns os.Interrupt for Windows (closest to SIGTERM).
func termSignal() os.Signal {
return os.Interrupt
}
// killSignal returns os.Kill for Windows.
func killSignal() os.Signal {
return os.Kill
}