From c7d226f8bb83633f96b1361a4f20bbc8a6dc0c9c Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Fri, 14 Jul 2023 11:27:27 -0400 Subject: [PATCH] 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. --- cmd/cgr-engine/cgr-engine.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index f230c1b4b..ed77e3173 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -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)