From 47d4d5bf1b8ecdc921fffab4ba22182f8d73fa74 Mon Sep 17 00:00:00 2001 From: greatroar <@> Date: Thu, 12 Mar 2020 19:55:46 +0100 Subject: [PATCH] Make all signal.Notify channels buffered --- cmd/restic/cleanup.go | 2 +- internal/restic/lock.go | 2 +- internal/restic/progress_unix.go | 2 +- internal/restic/progress_unix_with_siginfo.go | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/restic/cleanup.go b/cmd/restic/cleanup.go index 728883452..2f3c15683 100644 --- a/cmd/restic/cleanup.go +++ b/cmd/restic/cleanup.go @@ -20,7 +20,7 @@ var cleanupHandlers struct { var stderr = os.Stderr func init() { - cleanupHandlers.ch = make(chan os.Signal) + cleanupHandlers.ch = make(chan os.Signal, 1) go CleanupHandler(cleanupHandlers.ch) signal.Notify(cleanupHandlers.ch, syscall.SIGINT) } diff --git a/internal/restic/lock.go b/internal/restic/lock.go index 142fa4b73..28807ce69 100644 --- a/internal/restic/lock.go +++ b/internal/restic/lock.go @@ -253,7 +253,7 @@ var ignoreSIGHUP sync.Once func init() { ignoreSIGHUP.Do(func() { go func() { - c := make(chan os.Signal) + c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGHUP) for s := range c { debug.Log("Signal received: %v\n", s) diff --git a/internal/restic/progress_unix.go b/internal/restic/progress_unix.go index 30954ed31..d2cd08350 100644 --- a/internal/restic/progress_unix.go +++ b/internal/restic/progress_unix.go @@ -11,7 +11,7 @@ import ( ) func init() { - c := make(chan os.Signal) + c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR1) go func() { for s := range c { diff --git a/internal/restic/progress_unix_with_siginfo.go b/internal/restic/progress_unix_with_siginfo.go index b27193a89..eb94216e8 100644 --- a/internal/restic/progress_unix_with_siginfo.go +++ b/internal/restic/progress_unix_with_siginfo.go @@ -11,9 +11,8 @@ import ( ) func init() { - c := make(chan os.Signal) - signal.Notify(c, syscall.SIGUSR1) - signal.Notify(c, syscall.SIGINFO) + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGINFO, syscall.SIGUSR1) go func() { for s := range c { debug.Log("Signal received: %v\n", s)