Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion go/platform_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions go/platform_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading