From b7f3a1367af4af5b6914581a02a151e8e2594fb4 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 8 Jun 2026 21:17:36 +0200 Subject: [PATCH] repository: add SIGHUP handler only on Unix systems --- internal/repository/lock_file.go | 17 ----------------- internal/repository/lock_file_unix.go | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/repository/lock_file.go b/internal/repository/lock_file.go index 7cf5c549e..ac83cd9e0 100644 --- a/internal/repository/lock_file.go +++ b/internal/repository/lock_file.go @@ -4,10 +4,8 @@ import ( "context" "fmt" "os" - "os/signal" "os/user" "sync" - "syscall" "testing" "time" @@ -409,21 +407,6 @@ func (l *lockHandle) String() string { return text } -// listen for incoming SIGHUP and ignore -var ignoreSIGHUP sync.Once - -func init() { - ignoreSIGHUP.Do(func() { - go func() { - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGHUP) - for s := range c { - debug.Log("Signal received: %v\n", s) - } - }() - }) -} - // LoadLock loads and unserializes a lock from a repository. func LoadLock(ctx context.Context, repo restic.LoaderUnpacked, id restic.ID) (Lock, error) { var lock Lock diff --git a/internal/repository/lock_file_unix.go b/internal/repository/lock_file_unix.go index 38b6c5016..0133c2fa9 100644 --- a/internal/repository/lock_file_unix.go +++ b/internal/repository/lock_file_unix.go @@ -4,11 +4,28 @@ package repository import ( "os" + "os/signal" + "sync" "syscall" "github.com/restic/restic/internal/debug" ) +// listen for incoming SIGHUP and ignore +var ignoreSIGHUP sync.Once + +func init() { + ignoreSIGHUP.Do(func() { + go func() { + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGHUP) + for s := range c { + debug.Log("Signal received: %v\n", s) + } + }() + }) +} + // checkProcess will check if the process retaining the lock // exists and responds to SIGHUP signal. // Returns true if the process exists and responds.