summaryrefslogtreecommitdiff
path: root/libpod/shutdown/handler.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-12-07 10:00:36 -0500
committerMatthew Heon <mheon@redhat.com>2020-12-07 10:00:36 -0500
commitbd2cfe0a9336b01122de851c528ad7f3e521af78 (patch)
treedefcf4416ed8d6274705eecbd2236a50d3a3ccdf /libpod/shutdown/handler.go
parentdc5da90523f35146f5368a31be7edf39be13beb4 (diff)
downloadpodman-bd2cfe0a9336b01122de851c528ad7f3e521af78.tar.gz
podman-bd2cfe0a9336b01122de851c528ad7f3e521af78.tar.bz2
podman-bd2cfe0a9336b01122de851c528ad7f3e521af78.zip
Do not error on installing duplicate shutdown handler
Installing a duplicate shutdown handler fails, but if a handler with the same name is already present, we should be set to go. There's no reason to print a user-facing error about it. This comes up almost nowhere because Podman never makes more than one Libpod runtime, but there is one exception (`system reset`) and the error messages, while harmless, were making people very confused (we got several bug reports that `system reset` was nonfunctional). Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/shutdown/handler.go')
-rw-r--r--libpod/shutdown/handler.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/libpod/shutdown/handler.go b/libpod/shutdown/handler.go
index 87538dec9..f0f228b19 100644
--- a/libpod/shutdown/handler.go
+++ b/libpod/shutdown/handler.go
@@ -11,6 +11,10 @@ import (
)
var (
+ ErrHandlerExists error = errors.New("handler with given name already exists")
+)
+
+var (
stopped bool
sigChan chan os.Signal
cancelChan chan bool
@@ -98,7 +102,7 @@ func Register(name string, handler func(os.Signal) error) error {
}
if _, ok := handlers[name]; ok {
- return errors.Errorf("handler with name %s already exists", name)
+ return ErrHandlerExists
}
handlers[name] = handler