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

Function ForwardAllSignals

cli/command/container/signals.go:16–58  ·  view source on GitHub ↗

ForwardAllSignals forwards signals to the container The channel you pass in must already be setup to receive any signals you want to forward.

(ctx context.Context, apiClient client.ContainerAPIClient, cid string, sigc <-chan os.Signal)

Source from the content-addressed store, hash-verified

14//
15// The channel you pass in must already be setup to receive any signals you want to forward.
16func ForwardAllSignals(ctx context.Context, apiClient client.ContainerAPIClient, cid string, sigc <-chan os.Signal) {
17 var (
18 s os.Signal
19 ok bool
20 )
21 for {
22 select {
23 case s, ok = <-sigc:
24 if !ok {
25 return
26 }
27 case <-ctx.Done():
28 return
29 }
30
31 if s == signal.SIGCHLD || s == signal.SIGPIPE {
32 continue
33 }
34
35 // In go1.14+, the go runtime issues SIGURG as an interrupt to support pre-emptable system calls on Linux.
36 // Since we can't forward that along we'll check that here.
37 if isRuntimeSig(s) {
38 continue
39 }
40 var sig string
41 for sigStr, sigN := range signal.SignalMap {
42 if sigN == s {
43 sig = sigStr
44 break
45 }
46 }
47 if sig == "" {
48 continue
49 }
50
51 _, err := apiClient.ContainerKill(ctx, cid, client.ContainerKillOptions{
52 Signal: sig,
53 })
54 if err != nil {
55 logrus.Debugf("Error sending signal: %s", err)
56 }
57 }
58}
59
60func notifyAllSignals() chan os.Signal {
61 sigc := make(chan os.Signal, 128)

Callers 5

RunStartFunction · 0.85
RunAttachFunction · 0.85
TestIgnoredSignalsFunction · 0.85
runContainerFunction · 0.85
TestForwardSignalsFunction · 0.85

Calls 2

ContainerKillMethod · 0.80
isRuntimeSigFunction · 0.70

Tested by 2

TestIgnoredSignalsFunction · 0.68
TestForwardSignalsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…