MCPcopy Create free account
hub / github.com/cli/cli / containCommand

Function containCommand

script/ghmock/process_unix.go:16–28  ·  view source on GitHub ↗

containCommand gives a command and its Git children one process group so cancelling a run does not leave a transport or pack process behind. A PTY creates its own session instead.

(cmd *exec.Cmd, terminal bool)

Source from the content-addressed store, hash-verified

14// cancelling a run does not leave a transport or pack process behind. A PTY
15// creates its own session instead.
16func containCommand(cmd *exec.Cmd, terminal bool) {
17 if !terminal {
18 cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
19 }
20 cmd.WaitDelay = 5 * time.Second
21 cmd.Cancel = func() error {
22 err := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
23 if errors.Is(err, syscall.ESRCH) {
24 return os.ErrProcessDone
25 }
26 return err
27 }
28}

Callers 4

serveGitHTTPMethod · 0.70
runBinaryFunction · 0.70
cmdGitFunction · 0.70
localGitFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected