mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 00:33:57 +00:00
Allow suspending SIGINT handler
This commit is contained in:
parent
8f9bf1995b
commit
45a09c76ff
@ -14,15 +14,25 @@ var cleanupHandlers struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
list []func() error
|
list []func() error
|
||||||
done bool
|
done bool
|
||||||
|
sigintCh chan os.Signal
|
||||||
}
|
}
|
||||||
|
|
||||||
var stderr = os.Stderr
|
var stderr = os.Stderr
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
c := make(chan os.Signal)
|
cleanupHandlers.sigintCh = make(chan os.Signal)
|
||||||
signal.Notify(c, syscall.SIGINT)
|
go CleanupHandler(cleanupHandlers.sigintCh)
|
||||||
|
InstallSignalHandler()
|
||||||
|
}
|
||||||
|
|
||||||
go CleanupHandler(c)
|
// InstallSignalHandler listens for SIGINT and triggers the cleanup handlers.
|
||||||
|
func InstallSignalHandler() {
|
||||||
|
signal.Notify(cleanupHandlers.sigintCh, syscall.SIGINT)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SuspendSignalHandler removes the signal handler for SIGINT.
|
||||||
|
func SuspendSignalHandler() {
|
||||||
|
signal.Reset(syscall.SIGINT)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddCleanupHandler adds the function f to the list of cleanup handlers so
|
// AddCleanupHandler adds the function f to the list of cleanup handlers so
|
||||||
|
Loading…
Reference in New Issue
Block a user