mirror of
https://github.com/restic/restic.git
synced 2026-06-17 14:14:19 +00:00
repository: add SIGHUP handler only on Unix systems
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user