summaryrefslogtreecommitdiff
path: root/pkg
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 /pkg
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 'pkg')
-rw-r--r--pkg/api/server/server.go10
-rw-r--r--pkg/domain/infra/abi/terminal/sigproxy_linux.go5
2 files changed, 9 insertions, 6 deletions
diff --git a/pkg/api/server/server.go b/pkg/api/server/server.go
index cc5b45a65..24ad1874b 100644
--- a/pkg/api/server/server.go
+++ b/pkg/api/server/server.go
@@ -190,6 +190,9 @@ func (s *APIServer) Serve() error {
}); err != nil {
return err
}
+ // Unregister the libpod handler, which just calls exit(1).
+ // Ignore errors if it doesn't exist.
+ _ = shutdown.Unregister("libpod")
errChan := make(chan error, 1)
@@ -226,12 +229,7 @@ func (s *APIServer) Serve() error {
errChan <- nil
}()
- select {
- case err := <-errChan:
- return err
- }
-
- return nil
+ return <-errChan
}
// Shutdown is a clean shutdown waiting on existing clients
diff --git a/pkg/domain/infra/abi/terminal/sigproxy_linux.go b/pkg/domain/infra/abi/terminal/sigproxy_linux.go
index f484e926c..0c586cf5c 100644
--- a/pkg/domain/infra/abi/terminal/sigproxy_linux.go
+++ b/pkg/domain/infra/abi/terminal/sigproxy_linux.go
@@ -5,12 +5,17 @@ import (
"syscall"
"github.com/containers/podman/v2/libpod"
+ "github.com/containers/podman/v2/libpod/shutdown"
"github.com/containers/podman/v2/pkg/signal"
"github.com/sirupsen/logrus"
)
// ProxySignals ...
func ProxySignals(ctr *libpod.Container) {
+ // Stop catching the shutdown signals (SIGINT, SIGTERM) - they're going
+ // to the container now.
+ shutdown.Stop()
+
sigBuffer := make(chan os.Signal, 128)
signal.CatchAll(sigBuffer)