MCPcopy Index your code
hub / github.com/docker/cli / kill

Method kill

cli/connhelper/commandconn/commandconn.go:95–118  ·  view source on GitHub ↗

kill terminates the process. On Windows it kills the process directly, whereas on other platforms, a SIGTERM is sent, before forcefully terminating the process after 3 seconds.

()

Source from the content-addressed store, hash-verified

93// whereas on other platforms, a SIGTERM is sent, before forcefully terminating
94// the process after 3 seconds.
95func (c *commandConn) kill() {
96 if c.cmdExited.Load() {
97 return
98 }
99 c.cmdMutex.Lock()
100 var werr error
101 if runtime.GOOS != "windows" {
102 werrCh := make(chan error)
103 go func() { werrCh <- c.cmd.Wait() }()
104 _ = c.cmd.Process.Signal(syscall.SIGTERM)
105 select {
106 case werr = <-werrCh:
107 case <-time.After(3 * time.Second):
108 _ = c.cmd.Process.Kill()
109 werr = <-werrCh
110 }
111 } else {
112 _ = c.cmd.Process.Kill()
113 werr = c.cmd.Wait()
114 }
115 c.cmdWaitErr = werr
116 c.cmdMutex.Unlock()
117 c.cmdExited.Store(true)
118}
119
120// handleEOF handles io.EOF errors while reading or writing from the underlying
121// command pipes.

Callers 2

CloseReadMethod · 0.95
CloseWriteMethod · 0.95

Calls 1

StoreMethod · 0.65

Tested by

no test coverage detected