Use a buffered os.Signal channel as argument to signal.Notify

signal.Notify documentation states that:

Package signal will not block sending to c: the caller must ensure that c
has sufficient buffer space to keep up with the expected signal rate. For a
channel used for notification of just one signal value, a buffer of size 1
is sufficient.
This commit is contained in:
ionutboangiu
2023-07-14 11:27:27 -04:00
committed by Dan Christian Bogos
parent 78077ae454
commit c7d226f8bb

View File

@@ -292,8 +292,8 @@ func cpuProfiling(cpuProfDir string, stopChan, doneChan chan struct{}, exitChan
}
func singnalHandler(exitChan chan bool) {
shutdownSignal := make(chan os.Signal)
reloadSignal := make(chan os.Signal)
shutdownSignal := make(chan os.Signal, 1)
reloadSignal := make(chan os.Signal, 1)
signal.Notify(shutdownSignal, os.Interrupt,
syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
signal.Notify(reloadSignal, syscall.SIGHUP)