From 8021114b23ab5149fdb623bb44f61749ca7882bc Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 11 May 2026 15:59:22 -0400 Subject: [PATCH] fix(server): keep the spawned server alive after the parent exits The parent process was creating the detached server via a context-bound command, so when the parent exited or its context was cancelled the runtime would also kill the brand new server we had just spawned. Drop the context binding and rely on the existing platform-specific detach to give the server a life of its own. Co-Authored-By: Charm Crush --- internal/cmd/root.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/cmd/root.go b/internal/cmd/root.go index 80e126d4b85dd7fc3a3618f48707639d61869d91..1674fe0ca8b2569915543853527be79153e6b237 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -569,7 +569,11 @@ func startDetachedServer(cmd *cobra.Command) error { cmdArgs = append(cmdArgs, "--host", clientHost) } - c := exec.CommandContext(cmd.Context(), exe, cmdArgs...) + // Use exec.Command (not exec.CommandContext) so the parent's context + // cancellation does not kill the spawned server. detachProcess + // (Setsid on !windows, DETACHED_PROCESS on windows) is what truly + // detaches the child from this process's lifetime. + c := exec.Command(exe, cmdArgs...) stdoutPath := filepath.Join(chDir, "stdout.log") stderrPath := filepath.Join(chDir, "stderr.log") detachProcess(c)