mirror of
https://github.com/containers/podman.git
synced 2025-06-22 09:58:10 +08:00
Merge pull request #8629 from mheon/no_error_on_dupe_handler
Do not error on installing duplicate shutdown handler
This commit is contained in:
@ -190,7 +190,7 @@ func newRuntimeFromConfig(ctx context.Context, conf *config.Config, options ...R
|
||||
if err := shutdown.Register("libpod", func(sig os.Signal) error {
|
||||
os.Exit(1)
|
||||
return nil
|
||||
}); err != nil {
|
||||
}); err != nil && errors.Cause(err) != shutdown.ErrHandlerExists {
|
||||
logrus.Errorf("Error registering shutdown handler for libpod: %v", err)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,10 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrHandlerExists error = errors.New("handler with given name already exists")
|
||||
)
|
||||
|
||||
var (
|
||||
stopped bool
|
||||
sigChan chan os.Signal
|
||||
@ -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
|
||||
|
Reference in New Issue
Block a user