From 40fa350dffd2e3ecbe6944ff43ae7c2c32f3a10b Mon Sep 17 00:00:00 2001 From: SataQiu Date: Tue, 14 Sep 2021 11:47:34 +0800 Subject: [PATCH] use buffered channel for signal notifications Signed-off-by: SataQiu --- cmd/yurt-tunnel-server/server.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/yurt-tunnel-server/server.go b/cmd/yurt-tunnel-server/server.go index 84b328f113f..0f588aacee8 100644 --- a/cmd/yurt-tunnel-server/server.go +++ b/cmd/yurt-tunnel-server/server.go @@ -32,7 +32,10 @@ func main() { klog.InitFlags(nil) defer klog.Flush() - s := make(chan os.Signal) + // Set up channel on which to send signal notifications. + // We must use a buffered channel or risk missing the signal + // if we're not ready to receive when the signal is sent. + s := make(chan os.Signal, 1) signal.Notify(s, syscall.SIGINT, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT) stop := make(chan struct{})