on main help sign in
fix(server): keep the spawned server alive after the parent exits
8021114Christian Rocha
internal/cmd/root.go+5−1
@@ -569,7 +569,11 @@ func startDetachedServer(cmd *cobra.Command) error {
569 cmdArgs = append(cmdArgs, "--host", clientHost)
569 cmdArgs = append(cmdArgs, "--host", clientHost)
570 }
570 }
571
571
572+ // Use exec.Command (not exec.CommandContext) so the parent's context
573+ // cancellation does not kill the spawned server. detachProcess
574+ // (Setsid on !windows, DETACHED_PROCESS on windows) is what truly
575+ // detaches the child from this process's lifetime.
572− c := exec.CommandContext(cmd.Context(), exe, cmdArgs...)
576+ c := exec.Command(exe, cmdArgs...)
573 stdoutPath := filepath.Join(chDir, "stdout.log")
577 stdoutPath := filepath.Join(chDir, "stdout.log")
574 stderrPath := filepath.Join(chDir, "stderr.log")
578 stderrPath := filepath.Join(chDir, "stderr.log")
575 detachProcess(c)
579 detachProcess(c)