Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Signals are all interrupt signals.
As opposed to os.Interrupt, this adds syscall.SIGTERM for unix-like platforms. For other platforms, this is just os.Interrupt
Functions ¶
func Handle ¶ added in v1.46.0
Handle returns a copy of the parent context.Context that is marked done when an interrupt signal arrives or when the parent Context's Done channel is closed, whichever happens first.
Signal handling is unregistered automatically by this function when the first interrupt signal arrives, which will restore the default interrupt signal behavior of Go programs (to exit).
In effect, this function is functionally equivalent to:
ctx, cancel := signal.NotifyContext(ctx, interrupt.Signals...)
go func() {
<-ctx.Done()
cancel()
}()
Most programs should wrap their contexts using this function to enable interrupt signal handling. The first interrupt signal will result in the context's Done channel closing. The second interrupt signal will result in the program exiting.
func main() {
ctx := interrupt.Handle(context.Background())
...
}
Types ¶
This section is empty.