Skip to content

Commit 238712b

Browse files
authored
fix: cross-platform build for SysProcAttr (#11)
Move syscall.SysProcAttr{Setpgid: true} behind build tags so the binary compiles on Windows where Setpgid does not exist.
1 parent e089604 commit 238712b

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎cmd/dynamic.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"os/exec"
88
"strconv"
99
"strings"
10-
"syscall"
1110
"time"
1211

1312
"github.com/pipeboard-co/pipeboard-cli/internal/client"
@@ -69,7 +68,7 @@ func maybeAutoRefresh(cache *ToolsCache) {
6968
}
7069
cmd := exec.Command(self, "refresh", "--if-changed")
7170
cmd.Env = append(os.Environ(), "PIPEBOARD_AUTO_REFRESH=1")
72-
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
71+
setSysProcAttr(cmd)
7372
cmd.Stdout = nil
7473
cmd.Stderr = nil
7574
_ = cmd.Start()

‎cmd/proc_unix.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//go:build !windows
2+
3+
package cmd
4+
5+
import (
6+
"os/exec"
7+
"syscall"
8+
)
9+
10+
// setSysProcAttr detaches the subprocess into its own process group
11+
// so it survives after the parent exits.
12+
func setSysProcAttr(cmd *exec.Cmd) {
13+
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
14+
}

‎cmd/proc_windows.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build windows
2+
3+
package cmd
4+
5+
import "os/exec"
6+
7+
// setSysProcAttr is a no-op on Windows; the subprocess runs independently
8+
// by default when stdout/stderr are nil.
9+
func setSysProcAttr(cmd *exec.Cmd) {}

0 commit comments

Comments
 (0)