| 1 | // Copyright 2024 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | //go:build windows |
| 6 | |
| 7 | package telemetry |
| 8 | |
| 9 | import ( |
| 10 | "os/exec" |
| 11 | "syscall" |
| 12 | |
| 13 | "golang.org/x/sys/windows" |
| 14 | ) |
| 15 | |
| 16 | func init() { |
| 17 | daemonize = daemonizeWindows |
| 18 | } |
| 19 | |
| 20 | func daemonizeWindows(cmd *exec.Cmd) { |
| 21 | // Set DETACHED_PROCESS creation flag so that closing |
| 22 | // the console window the parent process was run in |
| 23 | // does not kill the child. |
| 24 | // See documentation of creation flags in the Microsoft documentation: |
| 25 | // https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags |
| 26 | cmd.SysProcAttr = &syscall.SysProcAttr{ |
| 27 | CreationFlags: windows.DETACHED_PROCESS, |
| 28 | } |
| 29 | } |