summaryrefslogtreecommitdiff
path: root/libpod/shutdown
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-10-12 15:10:52 -0400
committerMatthew Heon <mheon@redhat.com>2020-10-12 17:08:26 -0400
commit83e6e4ccdd925fa25500cff9e4b631b2c5d157cb (patch)
tree5dcbaee6ea381925c0258f95d7b134750c7adbb6 /libpod/shutdown
parent8381f3feeebbbeef269909e4abba83191c8d9590 (diff)
downloadpodman-83e6e4ccdd925fa25500cff9e4b631b2c5d157cb.tar.gz
podman-83e6e4ccdd925fa25500cff9e4b631b2c5d157cb.tar.bz2
podman-83e6e4ccdd925fa25500cff9e4b631b2c5d157cb.zip
Enable masking stop signals within container creation
Expand the use of the Shutdown package such that we now use it to handle signals any time we run Libpod. From there, add code to container creation to use the Inhibit function to prevent a shutdown from occuring during the critical parts of container creation. We also need to turn off signal handling when --sig-proxy is invoked - we don't want to catch the signals ourselves then, but instead to forward them into the container via the existing sig-proxy handler. Fixes #7941 Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/shutdown')
-rw-r--r--libpod/shutdown/handler.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/shutdown/handler.go b/libpod/shutdown/handler.go
index 79f236ab6..7abaf065b 100644
--- a/libpod/shutdown/handler.go
+++ b/libpod/shutdown/handler.go
@@ -84,6 +84,10 @@ func Uninhibit() {
// Register registers a function that will be executed when Podman is terminated
// by a signal.
func Register(name string, handler func() error) error {
+ if handlers == nil {
+ handlers = make(map[string]func() error)
+ }
+
if _, ok := handlers[name]; ok {
return errors.Errorf("handler with name %s already exists", name)
}
@@ -95,6 +99,10 @@ func Register(name string, handler func() error) error {
// Unregister un-registers a given shutdown handler.
func Unregister(name string) error {
+ if handlers == nil {
+ handlers = make(map[string]func() error)
+ }
+
if _, ok := handlers[name]; !ok {
return errors.Errorf("no handler with name %s found", name)
}