2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 22:27:35 +00:00

Ignore SIGPIPE

Handling SIGPIPE made restic abort when a TCP connection was reset by a
server. This happened on DigitalOcean Spaces, which uses the s3 backend.
This commit is contained in:
Alexander Neumann 2017-11-30 21:23:43 +01:00
parent 812ce4bfc4
commit 2579fe6b7b

View File

@ -25,16 +25,14 @@ func init() {
InstallSignalHandler() InstallSignalHandler()
} }
// InstallSignalHandler listens for SIGINT and SIGPIPE, and triggers the cleanup handlers. // InstallSignalHandler listens for SIGINT, and triggers the cleanup handlers.
func InstallSignalHandler() { func InstallSignalHandler() {
signal.Notify(cleanupHandlers.ch, syscall.SIGINT) signal.Notify(cleanupHandlers.ch, syscall.SIGINT)
signal.Notify(cleanupHandlers.ch, syscall.SIGPIPE)
} }
// SuspendSignalHandler removes the signal handler for SIGINT and SIGPIPE. // SuspendSignalHandler removes the signal handler for SIGINT.
func SuspendSignalHandler() { func SuspendSignalHandler() {
signal.Reset(syscall.SIGINT) signal.Reset(syscall.SIGINT)
signal.Reset(syscall.SIGPIPE)
} }
// AddCleanupHandler adds the function f to the list of cleanup handlers so // AddCleanupHandler adds the function f to the list of cleanup handlers so
@ -69,7 +67,7 @@ func RunCleanupHandlers() {
cleanupHandlers.list = nil cleanupHandlers.list = nil
} }
// CleanupHandler handles the SIGINT and SIGPIPE signals. // CleanupHandler handles the SIGINT signals.
func CleanupHandler(c <-chan os.Signal) { func CleanupHandler(c <-chan os.Signal) {
for s := range c { for s := range c {
debug.Log("signal %v received, cleaning up", s) debug.Log("signal %v received, cleaning up", s)