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
7 changes: 2 additions & 5 deletions internal/core/services/server_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"os"
"os/exec"
"regexp"
"runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -222,11 +221,9 @@ func (s *serverService) StartForward(alias string, extraArgs []string) (int, err
cmd.Stdin = devNull
cmd.Stdout = devNull
cmd.Stderr = devNull
// Set SysProcAttr conditionally to avoid Windows-only build issues
// Set SysProcAttr in an OS-specific way (see sysprocattr_* files)
sysProcAttr := &syscall.SysProcAttr{}
if runtime.GOOS != "windows" {
sysProcAttr.Setsid = true
}
setDetach(sysProcAttr)
cmd.SysProcAttr = sysProcAttr

if err := cmd.Start(); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions internal/core/services/sysprocattr_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build !windows

package services

import "syscall"

// setDetach configures SysProcAttr to detach the process on non-Windows platforms.
func setDetach(attr *syscall.SysProcAttr) {
// On Unix-like systems, Setsid creates a new session to fully detach.
attr.Setsid = true
}
10 changes: 10 additions & 0 deletions internal/core/services/sysprocattr_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build windows

package services

import "syscall"

// setDetach is a no-op on Windows because syscall.SysProcAttr does not have Setsid.
func setDetach(attr *syscall.SysProcAttr) {
// No detachment tweak needed; Windows uses different process group semantics.
}