internal/gitutil/proc_unix.go

28e72be7ab6bc96868893853fd8d210c3656960f
gitbay/internal/gitutil/proc_unix.go

26 lines · 527 bytes

 1//go:build unix
 2
 3package gitutil
 4
 5import (
 6	"os/exec"
 7	"syscall"
 8)
 9
10// ownProcessGroup puts cmd in a process group of its own, so killTree
11// ends what it started too: receive-pack runs index-pack and the hooks.
12func ownProcessGroup(cmd *exec.Cmd) {
13	if cmd.SysProcAttr == nil {
14		cmd.SysProcAttr = &syscall.SysProcAttr{}
15	}
16	cmd.SysProcAttr.Setpgid = true
17}
18
19func killTree(cmd *exec.Cmd) {
20	if cmd.Process == nil {
21		return
22	}
23	if err := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL); err != nil {
24		cmd.Process.Kill()
25	}
26}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form