//go:build windows package main import ( "os/exec" "syscall" ) // detachProcess starts the child on its own, the way PowerShell's Start-Process // left the relaunched OpsLog. // // DETACHED_PROCESS gives it no console of ours, CREATE_NEW_PROCESS_GROUP takes // it out of our group so a Ctrl-Break or a job-object cleanup aimed at the old // instance cannot reach the new one. Deliberately NOT CREATE_NO_WINDOW and NOT // HideWindow: SW_HIDE in the STARTUPINFO is what made the updated OpsLog start // invisibly, and there is no console to suppress — OpsLog is linked for the // Windows GUI subsystem. func detachProcess(cmd *exec.Cmd) { const ( detachedProcess = 0x00000008 createNewProcessGroup = 0x00000200 ) cmd.SysProcAttr = &syscall.SysProcAttr{ CreationFlags: detachedProcess | createNewProcessGroup, } }