返回 DeepSeek-Reasonix
shell_kill_other.go
根目录 / internal / control / shell_kill_other.go
1 //go:build !windows
2
3 package control
4
5 import (
6 "os/exec"
7 "syscall"
8 )
9
10 // setShellKillTree makes cancellation kill the whole shell tree. Running the
11 // child in a new session also keeps interactive prompts from grabbing the TUI's
12 // controlling terminal.
13 func setShellKillTree(cmd *exec.Cmd) {
14 cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
15 cmd.Cancel = func() error {
16 if cmd.Process == nil {
17 return nil
18 }
19 return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
20 }
21 }
22
22 lines GO