fix: solve windows build issue

This commit is contained in:
Adem Baccara
2025-10-08 21:31:47 +01:00
parent 20fb256c29
commit 68dc0163ed
3 changed files with 23 additions and 5 deletions
+2 -5
View File
@@ -21,7 +21,6 @@ import (
"os"
"os/exec"
"regexp"
"runtime"
"sort"
"strconv"
"strings"
@@ -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 {
@@ -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
}
@@ -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.
}