Skip to content

Commit 5985101

Browse files
engalarclaude
andcommitted
fix(windows): CREATE_BREAKAWAY_FROM_JOB to survive PowerShell pipelines
PowerShell uses Windows Job Objects to manage pipeline processes. When the launcher exits, the Job Object kills all child processes — including the daemon that was just spawned — forcing a full cold restart on every command. Add CREATE_BREAKAWAY_FROM_JOB (0x01000000) to the daemon's CreationFlags so it is detached from the parent Job Object and survives launcher exit. Without this fix: daemon killed after every invocation from PowerShell, hot-path took 4-15s due to repeated cold restarts. With this fix: daemon persists across launcher exits, hot-path ~600ms. Git Bash was unaffected because it does not use Job Objects for child process tracking. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 3934c4e commit 5985101

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

cmd/mxcli-launcher/spawn_windows.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,19 @@ import (
99
"syscall"
1010
)
1111

12-
// hideDaemonWindow prevents a console window from flashing when the daemon
13-
// process is started in the background on Windows.
12+
const (
13+
// createBreakawayFromJob detaches the child process from the parent's
14+
// Job Object. Without this flag, PowerShell pipelines (which use Job
15+
// Objects) kill all child processes when the launcher exits — causing
16+
// the daemon to be killed on every invocation and forcing cold restarts.
17+
createBreakawayFromJob = 0x01000000
18+
)
19+
20+
// hideDaemonWindow hides the console window and detaches the daemon from the
21+
// launcher's Job Object so it survives across PowerShell pipeline boundaries.
1422
func hideDaemonWindow(cmd *exec.Cmd) {
15-
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
23+
cmd.SysProcAttr = &syscall.SysProcAttr{
24+
HideWindow: true,
25+
CreationFlags: createBreakawayFromJob,
26+
}
1627
}

0 commit comments

Comments
 (0)