MCPcopy Create free account
hub / github.com/brimdata/super / signalContext

Function signalContext

cli/cli.go:76–91  ·  view source on GitHub ↗
(ctx context.Context, signals ...os.Signal)

Source from the content-addressed store, hash-verified

74}
75
76func signalContext(ctx context.Context, signals ...os.Signal) (context.Context, context.CancelFunc) {
77 ctx, cancel := context.WithCancelCause(ctx)
78 ch := make(chan os.Signal, 1)
79 signal.Notify(ch, signals...)
80 go func() {
81 select {
82 case <-ctx.Done():
83 case s := <-ch:
84 cancel(fmt.Errorf("received %s signal", s))
85 }
86 }()
87 return ctx, func() {
88 cancel(nil)
89 signal.Stop(ch)
90 }
91}
92
93func (f *Flags) cleanup() {
94 if f.cpuProfileFile != nil {

Callers 1

InitWithSignalsMethod · 0.85

Calls 1

DoneMethod · 0.45

Tested by

no test coverage detected