Skip to content

Commit

Permalink
Merge pull request #6036 from giuseppe/fix-rootlessport-panic
Browse files Browse the repository at this point in the history
rootlessport: use two different channels
  • Loading branch information
openshift-merge-robot authored Apr 29, 2020
2 parents de77e4b + 6d545bb commit 6246165
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 14 additions & 12 deletions pkg/rootlessport/rootlessport_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
}
}()

Expand Down
2 changes: 2 additions & 0 deletions pkg/specgen/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down

0 comments on commit 6246165

Please sign in to comment.