Add native Windows support (#91)
- Native Windows daemon using TCP loopback endpoints - Direct-mode fallback for CLI/daemon compatibility - Comment operations over RPC - PowerShell installer script - Go 1.24 requirement - Cross-OS testing documented Co-authored-by: danshapiro <danshapiro@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-c6230265-055f-4af1-9712-4481061886db Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -3,14 +3,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
const stillActive = 259
|
||||
|
||||
var daemonSignals = []os.Signal{os.Interrupt, syscall.SIGTERM}
|
||||
|
||||
// configureDaemonProcess sets up platform-specific process attributes for daemon
|
||||
func configureDaemonProcess(cmd *exec.Cmd) {
|
||||
// Windows doesn't support Setsid, use CREATE_NEW_PROCESS_GROUP instead
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
|
||||
HideWindow: true,
|
||||
}
|
||||
}
|
||||
|
||||
func sendStopSignal(process *os.Process) error {
|
||||
if err := process.Signal(syscall.SIGTERM); err == nil {
|
||||
return nil
|
||||
}
|
||||
return process.Kill()
|
||||
}
|
||||
|
||||
func isReloadSignal(os.Signal) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func isProcessRunning(pid int) bool {
|
||||
handle, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
defer windows.CloseHandle(handle)
|
||||
|
||||
var code uint32
|
||||
if err := windows.GetExitCodeProcess(handle, &code); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return code == stillActive
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user