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

Function notifyContext

cmd/docker/docker.go:56–80  ·  view source on GitHub ↗
(ctx context.Context, signals ...os.Signal)

Source from the content-addressed store, hash-verified

54}
55
56func notifyContext(ctx context.Context, signals ...os.Signal) (context.Context, context.CancelFunc) {
57 ch := make(chan os.Signal, 1)
58 signal.Notify(ch, signals...)
59
60 ctxCause, cancel := context.WithCancelCause(ctx)
61
62 go func() {
63 select {
64 case <-ctx.Done():
65 signal.Stop(ch)
66 return
67 case sig := <-ch:
68 cancel(errCtxSignalTerminated{
69 signal: sig,
70 })
71 signal.Stop(ch)
72 return
73 }
74 }()
75
76 return ctxCause, func() {
77 signal.Stop(ch)
78 cancel(nil)
79 }
80}
81
82func dockerMain(ctx context.Context) error {
83 ctx, cancelNotify := notifyContext(ctx, platformsignals.TerminationSignals...)

Callers 2

dockerMainFunction · 0.85
TestUserTerminatedErrorFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestUserTerminatedErrorFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…