Merge pull request #6036 from giuseppe/fix-rootlessport-panic

rootlessport: use two different channels
This commit is contained in:
OpenShift Merge Robot
2020-04-29 16:07:44 +02:00
committed by GitHub
2 changed files with 16 additions and 12 deletions

View File

@ -102,19 +102,19 @@ func parent() error {
return err return err
} }
exitC := make(chan os.Signal, 1)
defer close(exitC)
go func() {
sigC := make(chan os.Signal, 1) sigC := make(chan os.Signal, 1)
signal.Notify(sigC, unix.SIGPIPE) signal.Notify(sigC, unix.SIGPIPE)
defer func() {
// dummy signal to terminate the goroutine
sigC <- unix.SIGKILL
}()
go func() {
defer func() { defer func() {
signal.Stop(sigC) signal.Stop(sigC)
close(sigC) close(sigC)
}() }()
s := <-sigC select {
case s := <-sigC:
if s == unix.SIGPIPE { if s == unix.SIGPIPE {
if f, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755); err == nil { 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()), 1) // nolint:errcheck
@ -122,6 +122,8 @@ func parent() error {
f.Close() f.Close()
} }
} }
case <-exitC:
}
}() }()
// create the parent driver // create the parent driver

View File

@ -216,6 +216,8 @@ func ParseNetworkNamespace(ns string) (Namespace, []string, error) {
toReturn := Namespace{} toReturn := Namespace{}
var cniNetworks []string var cniNetworks []string
switch { switch {
case ns == "slirp4netns":
toReturn.NSMode = Slirp
case ns == "pod": case ns == "pod":
toReturn.NSMode = FromPod toReturn.NSMode = FromPod
case ns == "bridge": case ns == "bridge":