| 1 | package util |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "io" |
| 6 | ) |
| 7 | |
| 8 | type ctxCloser context.CancelFunc |
| 9 | |
| 10 | func (c ctxCloser) Close() error { |
| 11 | c() |
| 12 | return nil |
| 13 | } |
| 14 | |
| 15 | func SetupInterruptHandler(ctx context.Context) (io.Closer, context.Context) { |
| 16 | ctx, cancel := context.WithCancel(ctx) |
| 17 | return ctxCloser(cancel), ctx |
| 18 | } |