From f63cb9246fb1ec0014946e8e38000015e9854c48 Mon Sep 17 00:00:00 2001 From: Snider Date: Tue, 24 Nov 2026 05:40:19 +0000 Subject: [PATCH] fix(windows): start children without a console window applyProcessGroup was a no-op on Windows, so every command a GUI app (-H windowsgui) ran through go-process flashed up an empty console window. Output is always piped back to the service, so the child never needs one: CREATE_NO_WINDOW + HideWindow. Found by Manga Shelf (Snider/manga), which runs mangadex-dl for each download. Co-Authored-By: Virgil --- go/platform_windows.go | 9 ++++++++- go/platform_windows_test.go | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) 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) {