//go:build windows package cli import ( "errors" "syscall" "golang.org/x/sys/windows" ) func processAlive(pid int) bool { if pid <= 0 { return false } handle, err := windows.OpenProcess(windows.SYNCHRONIZE, false, uint32(pid)) if err != nil { if errors.Is(err, windows.ERROR_ACCESS_DENIED) { return true } return false } defer windows.CloseHandle(handle) status, err := windows.WaitForSingleObject(handle, 0) if err != nil { return false } return status == uint32(windows.WAIT_TIMEOUT) } // detachSysProcAttr starts the daemon in a new process group so it does not // receive the console's CTRL_C/CTRL_BREAK while `ao start` waits for readiness. func detachSysProcAttr() *syscall.SysProcAttr { return &syscall.SysProcAttr{CreationFlags: windows.CREATE_NEW_PROCESS_GROUP} }