(ctx context.Context, signals ...os.Signal)
| 54 | } |
| 55 | |
| 56 | func 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 | |
| 82 | func dockerMain(ctx context.Context) error { |
| 83 | ctx, cancelNotify := notifyContext(ctx, platformsignals.TerminationSignals...) |
no outgoing calls
searching dependent graphs…