Handle spawning subprocess within windows

This commit is contained in:
Chiran Fernando 2025-05-18 14:19:36 +05:30
parent ad5185ad72
commit 68015ae8fc
5 changed files with 167 additions and 52 deletions

View file

@ -0,0 +1,23 @@
//go:build !windows
package subprocess
import (
"os/exec"
"syscall"
)
// setProcAttr sets Unix-specific process attributes
func setProcAttr(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}
// getProcessGroup gets the process group ID on Unix systems
func getProcessGroup(pid int) (int, error) {
return syscall.Getpgid(pid)
}
// killProcessGroup kills a process group on Unix systems
func killProcessGroup(pgid int, signal syscall.Signal) error {
return syscall.Kill(-pgid, signal)
}