25 lines
521 B
Go
25 lines
521 B
Go
//go:build unix
|
|
|
|
package gitx
|
|
|
|
import (
|
|
"syscall"
|
|
"time"
|
|
)
|
|
|
|
// sysProcAttr puts git in its own process group so we can signal the whole
|
|
// tree — git itself plus the ssh or git-remote-https helper it spawned.
|
|
func sysProcAttr() *syscall.SysProcAttr {
|
|
return &syscall.SysProcAttr{Setpgid: true}
|
|
}
|
|
|
|
// terminate asks the process group to exit, then insists.
|
|
func terminate(pid int) {
|
|
if pid <= 0 {
|
|
return
|
|
}
|
|
_ = syscall.Kill(-pid, syscall.SIGTERM)
|
|
time.Sleep(termGrace)
|
|
_ = syscall.Kill(-pid, syscall.SIGKILL)
|
|
}
|