Detach managed processes from run console

This commit is contained in:
npc0-hue
2026-08-31 04:58:24 +08:00
parent f63f0966ff
commit 90de21ad9f
2 changed files with 15 additions and 9 deletions
+3 -3
View File
@@ -12,7 +12,7 @@ import (
"golang.org/x/sys/windows"
)
func TestConfigureManagedProcessCommandPreservesInheritedConsole(t *testing.T) {
func TestConfigureManagedProcessCommandDetachesFromRunConsole(t *testing.T) {
cmd := exec.Command("cmd.exe")
configureManagedProcessCommand(cmd)
if cmd.SysProcAttr == nil {
@@ -21,9 +21,9 @@ func TestConfigureManagedProcessCommandPreservesInheritedConsole(t *testing.T) {
if !cmd.SysProcAttr.HideWindow {
t.Fatal("expected managed console window to stay hidden")
}
expected := uint32(windows.CREATE_NO_WINDOW | windows.CREATE_BREAKAWAY_FROM_JOB)
expected := uint32(windows.DETACHED_PROCESS | windows.CREATE_NEW_PROCESS_GROUP | windows.CREATE_BREAKAWAY_FROM_JOB)
if cmd.SysProcAttr.CreationFlags != expected {
t.Fatalf("expected a hidden breakaway helper without a console, got %#x", cmd.SysProcAttr.CreationFlags)
t.Fatalf("expected a detached breakaway helper isolated from Ctrl+C, got %#x", cmd.SysProcAttr.CreationFlags)
}
}