internal/gitcmd/cancel_unix.go
raw ยท 424 bytes
//go:build unix
package gitcmd
import (
"errors"
"os"
"os/exec"
"syscall"
)
func configureCancellation(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Cancel = func() error {
// Kill the whole process group, including git-remote-https / ssh.
err := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
if errors.Is(err, syscall.ESRCH) {
return os.ErrProcessDone
}
return err
}
}