MCPcopy
hub / github.com/smallstep/cli / signalHandler

Function signalHandler

exec/exec.go:200–218  ·  view source on GitHub ↗

signalHandler forwards all the signals to the cmd.

(cmd *exec.Cmd, exitCh chan int)

Source from the content-addressed store, hash-verified

198
199// signalHandler forwards all the signals to the cmd.
200func signalHandler(cmd *exec.Cmd, exitCh chan int) {
201 // signal.Notify prefers a buffered channel. From documentation: "For a
202 // channel used for notification of just one signal value, a buffer of size
203 // 1 is sufficient." As we do not know how many signal values the cmd is
204 // expecting we select 1 as a sane default. In the future maybe we can make
205 // this value configurable.
206 signals := make(chan os.Signal, 1)
207 signal.Notify(signals)
208 defer signal.Stop(signals)
209 for {
210 select {
211 case sig := <-signals:
212 cmd.Process.Signal(sig)
213 case code := <-exitCh:
214 //nolint:gocritic // ignore exitAfterDefer error - defer is required for recovery.
215 os.Exit(code)
216 }
217 }
218}

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…