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)