All checks were successful
release / build-and-upload (push) Successful in 7m2s
Dashboard Live uptimes + Recent runs from stream_sessions; overview.recent_sessions. WireGuard netns resolv.conf + missing-deps WARN. Support donations card. Agent start/stop/update, job_backoff default off, wvkey ensure/venv, phonecap retries, modhost YAML enrich, DRM SetCredentials requires keys.
46 lines
1,006 B
Go
46 lines
1,006 B
Go
//go:build windows
|
|
|
|
package agentcmd
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func detachProcess(cmd *exec.Cmd) {
|
|
// CREATE_NEW_PROCESS_GROUP so stop can target the child; keep stdio so
|
|
// stdout/stderr still reach the log file opened by the parent.
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
|
CreationFlags: windows.CREATE_NEW_PROCESS_GROUP,
|
|
}
|
|
}
|
|
|
|
func signalAlive(pid int) bool {
|
|
// On Windows, FindProcess always succeeds; use OpenProcess exit code instead.
|
|
h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
defer windows.CloseHandle(h)
|
|
var code uint32
|
|
if err := windows.GetExitCodeProcess(h, &code); err != nil {
|
|
return false
|
|
}
|
|
const stillActive = 259 // STILL_ACTIVE
|
|
return code == stillActive
|
|
}
|
|
|
|
func signalTerminate(pid int) error {
|
|
p, err := os.FindProcess(pid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return p.Kill()
|
|
}
|
|
|
|
func signalKill(pid int) error {
|
|
return signalTerminate(pid)
|
|
}
|