repository: add SIGHUP handler only on Unix systems

This commit is contained in:
Michael Eischer
2026-06-08 21:17:36 +02:00
parent 4838b0ae3e
commit b7f3a1367a
2 changed files with 17 additions and 17 deletions
-17
View File
@@ -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
+17
View File
@@ -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.