Skip to content

unbuffered-signal-channel

Default severity: warning

The os/signal package uses non-blocking sends to deliver notifications. If no receiver is immediately ready, an unbuffered channel drops the signal. Give the channel enough capacity for the signals being handled.

ch := make(chan os.Signal)
signal.Notify(ch, os.Interrupt)
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt)