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 configstore 8 9 import ( 10 "os/exec" 11 "syscall" 12 13 "golang.org/x/sys/windows" 14 ) 15 16 func init() { 17 needNoConsole = needNoConsoleWindows 18 } 19 20 func needNoConsoleWindows(cmd *exec.Cmd) { 21 // The uploader main process is likely a daemonized process with no console. 22 // (see x/telemetry/start_windows.go) The console creation behavior when 23 // a parent is a console process without console is not clearly documented 24 // but empirically we observed the new console is created and attached to the 25 // subprocess in the default setup. 26 // 27 // Ensure no new console is attached to the subprocess by setting CREATE_NO_WINDOW. 28 // https://learn.microsoft.com/en-us/windows/console/creation-of-a-console 29 // https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags 30 cmd.SysProcAttr = &syscall.SysProcAttr{ 31 CreationFlags: windows.CREATE_NO_WINDOW, 32 } 33 } 34