fix: add platform-specific sysproc for Windows and macOS
This commit is contained in:
parent
b2142f6a04
commit
7f145b350e
3 changed files with 19 additions and 5 deletions
12
sysproc_darwin.go
Normal file
12
sysproc_darwin.go
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setCommandSysProcAttr(cmd *exec.Cmd) {
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||||
|
Setpgid: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
//go:build !windows
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -7,9 +5,6 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
// setCommandSysProcAttr sets platform-specific process attributes.
|
|
||||||
// On Linux: sets a new process group so child processes don't receive
|
|
||||||
// terminal signals meant for the parent, and enables proper cleanup.
|
|
||||||
func setCommandSysProcAttr(cmd *exec.Cmd) {
|
func setCommandSysProcAttr(cmd *exec.Cmd) {
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||||
Setpgid: true,
|
Setpgid: true,
|
||||||
|
|
|
||||||
7
sysproc_windows.go
Normal file
7
sysproc_windows.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "os/exec"
|
||||||
|
|
||||||
|
func setCommandSysProcAttr(cmd *exec.Cmd) {
|
||||||
|
// Windows does not use Setpgid
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue