mirror of
https://github.com/containers/podman.git
synced 2025-07-26 18:02:40 +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:
libpod
@ -190,7 +190,7 @@ func newRuntimeFromConfig(ctx context.Context, conf *config.Config, options ...R
|
|||||||
if err := shutdown.Register("libpod", func(sig os.Signal) error {
|
if err := shutdown.Register("libpod", func(sig os.Signal) error {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
}); err != nil && errors.Cause(err) != shutdown.ErrHandlerExists {
|
||||||
logrus.Errorf("Error registering shutdown handler for libpod: %v", err)
|
logrus.Errorf("Error registering shutdown handler for libpod: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrHandlerExists error = errors.New("handler with given name already exists")
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
stopped bool
|
stopped bool
|
||||||
sigChan chan os.Signal
|
sigChan chan os.Signal
|
||||||
@ -98,7 +102,7 @@ func Register(name string, handler func(os.Signal) error) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := handlers[name]; ok {
|
if _, ok := handlers[name]; ok {
|
||||||
return errors.Errorf("handler with name %s already exists", name)
|
return ErrHandlerExists
|
||||||
}
|
}
|
||||||
|
|
||||||
handlers[name] = handler
|
handlers[name] = handler
|
||||||
|
Reference in New Issue
Block a user