diff --git a/go/platform_windows.go b/go/platform_windows.go index e8bf3e5..6c1436d 100644 --- a/go/platform_windows.go +++ b/go/platform_windows.go @@ -42,8 +42,15 @@ func signalCannotBeCaught(sig syscall.Signal) bool { return sig == syscall.SIGKILL } -// applyProcessGroup is a no-op until Windows Job Object lifecycle lands. +// createNoWindow is CREATE_NO_WINDOW: the child gets no console of its own. +const createNoWindow = 0x08000000 + +// applyProcessGroup starts the child without a console window. Its output is +// always piped back to the service, so a console would only be an empty +// black window flashing up over a GUI app (-H windowsgui) for every command. +// Process-group lifecycle (Job Objects) is still to come on Windows. func applyProcessGroup(cmd *core.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: createNoWindow} } // exitWasSignaled is always false on Windows. diff --git a/go/platform_windows_test.go b/go/platform_windows_test.go index 1677c2d..bff11cf 100644 --- a/go/platform_windows_test.go +++ b/go/platform_windows_test.go @@ -26,8 +26,8 @@ func TestPlatformWindowsSignalHelpers(t *testing.T) { cmd := &core.Cmd{} applyProcessGroup(cmd) - if cmd.SysProcAttr != nil { - t.Fatalf("applyProcessGroup configured SysProcAttr on Windows") + if cmd.SysProcAttr == nil || !cmd.SysProcAttr.HideWindow || cmd.SysProcAttr.CreationFlags&createNoWindow == 0 { + t.Fatalf("applyProcessGroup should start children without a console window: %+v", cmd.SysProcAttr) } if exitWasSignaled(nil) {