Files
kandev/apps/backend/internal/agentctl/server/process/procattr_unix.go
T
Carlos Florêncio 2ae26add46
release / build-web (push) Has been cancelled
release / build-bundles (aarch64-linux-gnu-gcc, arm64, linux, ubuntu-latest, linux-arm64) (push) Has been cancelled
release / build-bundles (amd64, darwin, macos-14, macos-x64) (push) Has been cancelled
release / build-bundles (amd64, linux, ubuntu-latest, linux-x64) (push) Has been cancelled
release / build-bundles (arm64, darwin, macos-14, macos-arm64) (push) Has been cancelled
release / build-bundles (x86_64-w64-mingw32-gcc, amd64, windows, ubuntu-latest, windows-x64) (push) Has been cancelled
release / publish-release (push) Has been cancelled
feat: improve vscode cleanup (#294)
2026-02-26 13:34:47 +00:00

29 lines
893 B
Go

//go:build unix && !linux
package process
import (
"os/exec"
"syscall"
)
// setProcGroup configures the command to run in its own process group.
// This allows us to kill all child processes together.
// Note: Pdeathsig is Linux-specific and not available on macOS/BSD.
// On these platforms, orphan cleanup relies on explicit Stop() calls.
func setProcGroup(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}
// killProcessGroup kills the entire process group for the given PID.
// Returns nil if successful, or an error if the kill failed.
func killProcessGroup(pid int) error {
// Kill the entire process group by using negative PID
return syscall.Kill(-pid, syscall.SIGKILL)
}
// terminateProcessGroup sends SIGTERM to the entire process group for graceful shutdown.
func terminateProcessGroup(pid int) error {
return syscall.Kill(-pid, syscall.SIGTERM)
}