diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-29 16:07:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 16:07:44 +0200 |
commit | 6246165f168ab1d619bf4650590e32e035893143 (patch) | |
tree | 5dff005e415649d0402dff2ff2e2e5c1cc6562c7 /pkg | |
parent | de77e4b3f12271e7ab8fe3c7e2c444032032acd2 (diff) | |
parent | 6d545bb2f773ff996ce28e0b6608380206835004 (diff) | |
download | podman-6246165f168ab1d619bf4650590e32e035893143.tar.gz podman-6246165f168ab1d619bf4650590e32e035893143.tar.bz2 podman-6246165f168ab1d619bf4650590e32e035893143.zip |
Merge pull request #6036 from giuseppe/fix-rootlessport-panic
rootlessport: use two different channels
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/rootlessport/rootlessport_linux.go | 26 | ||||
-rw-r--r-- | pkg/specgen/namespaces.go | 2 |
2 files changed, 16 insertions, 12 deletions
diff --git a/pkg/rootlessport/rootlessport_linux.go b/pkg/rootlessport/rootlessport_linux.go index 1c1ed39df..c686d80fc 100644 --- a/pkg/rootlessport/rootlessport_linux.go +++ b/pkg/rootlessport/rootlessport_linux.go @@ -102,25 +102,27 @@ func parent() error { return err } - sigC := make(chan os.Signal, 1) - signal.Notify(sigC, unix.SIGPIPE) - defer func() { - // dummy signal to terminate the goroutine - sigC <- unix.SIGKILL - }() + exitC := make(chan os.Signal, 1) + defer close(exitC) + go func() { + sigC := make(chan os.Signal, 1) + signal.Notify(sigC, unix.SIGPIPE) defer func() { signal.Stop(sigC) close(sigC) }() - s := <-sigC - if s == unix.SIGPIPE { - if f, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755); err == nil { - unix.Dup2(int(f.Fd()), 1) // nolint:errcheck - unix.Dup2(int(f.Fd()), 2) // nolint:errcheck - f.Close() + select { + case s := <-sigC: + if s == unix.SIGPIPE { + if f, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755); err == nil { + unix.Dup2(int(f.Fd()), 1) // nolint:errcheck + unix.Dup2(int(f.Fd()), 2) // nolint:errcheck + f.Close() + } } + case <-exitC: } }() diff --git a/pkg/specgen/namespaces.go b/pkg/specgen/namespaces.go index f0161a793..396563267 100644 --- a/pkg/specgen/namespaces.go +++ b/pkg/specgen/namespaces.go @@ -216,6 +216,8 @@ func ParseNetworkNamespace(ns string) (Namespace, []string, error) { toReturn := Namespace{} var cniNetworks []string switch { + case ns == "slirp4netns": + toReturn.NSMode = Slirp case ns == "pod": toReturn.NSMode = FromPod case ns == "bridge": |