Skip to content

Commit 3b9bd3a

Browse files
authored
Add freebsd (#229)
1 parent 66b6d55 commit 3b9bd3a

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

pkg/proctree/proctree_freebsd.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//go:build freebsd
2+
3+
package proctree
4+
5+
import (
6+
"syscall"
7+
)
8+
9+
func startPlatform(p *ProcTree) error {
10+
// Start the child in a new session (which also gives it a new process group
11+
// with pgid == child's pid). That lets us signal the entire tree via -pid.
12+
p.cmd.SysProcAttr = &syscall.SysProcAttr{
13+
Setsid: true,
14+
}
15+
return p.cmd.Start()
16+
}
17+
18+
func killPlatformTree(p *ProcTree) error {
19+
if p.cmd.Process == nil {
20+
return nil
21+
}
22+
// Signal the whole process group. Negative PID targets the PGID.
23+
_ = syscall.Kill(-p.cmd.Process.Pid, syscall.SIGKILL)
24+
return p.cmd.Process.Kill()
25+
}

0 commit comments

Comments
 (0)