fix: use build tags for Setpgid (Unix-only) to fix Windows build

This commit is contained in:
2026-05-26 14:46:36 +01:00
parent a81482d06a
commit a5b18140d3
3 changed files with 22 additions and 1 deletions
+12
View File
@@ -0,0 +1,12 @@
//go:build !windows
package hooks
import (
"os/exec"
"syscall"
)
func setSysProcAttr(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}
+9
View File
@@ -0,0 +1,9 @@
//go:build windows
package hooks
import "os/exec"
func setSysProcAttr(cmd *exec.Cmd) {
// Windows has no Setpgid; process groups work differently.
}
+1 -1
View File
@@ -334,7 +334,7 @@ func ensureWorkerRunningCtx(ctx context.Context) (int, error) {
// Start worker -- detach from hook's process group so Claude Code
// killing the hook doesn't take the worker down with it.
cmd := exec.Command(workerPath) // #nosec G204 -- workerPath is from internal findWorkerBinary
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
setSysProcAttr(cmd)
cmd.Stdout = os.Stderr
cmd.Stderr = os.Stderr
if err := cmd.Start(); err != nil {