zot/internal/agent/botcmd_windows.go
patriceckhart 682c64f494 fix ci on windows: split detach helper into posix/windows variants
syscall.SysProcAttr.Setsid is posix-only — unknown field on windows.
Extracted the detach-on-start logic into a detachChild function
variable, implemented in botcmd_unix.go (Setsid) and botcmd_windows.go
(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP creation flags).
2026-04-18 10:58:10 +02:00

21 lines
543 B
Go

//go:build windows
package agent
import (
"os/exec"
"syscall"
)
// detachChild spawns the bot in its own process group via the
// DETACHED_PROCESS + CREATE_NEW_PROCESS_GROUP creation flags. Windows
// has no direct setsid equivalent; these two flags combined give the
// child a clean console-less group that ctrl+c on the parent won't
// reach.
func init() {
detachChild = func(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{
CreationFlags: 0x00000008 | 0x00000200, // DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP
}
}
}