diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-22 20:27:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 20:27:58 +0100 |
commit | 98687ad4a603d5011db75a10e13599c5d241472d (patch) | |
tree | 417c10045babcbd7f2f44d3190d1797ccc8f5e7f /pkg | |
parent | dc23c3aed42a9b43d7c8bd69de1d1cf98c006761 (diff) | |
parent | bebc9d81456cab242c7effb64d9146e9f92f3e34 (diff) | |
download | podman-98687ad4a603d5011db75a10e13599c5d241472d.tar.gz podman-98687ad4a603d5011db75a10e13599c5d241472d.tar.bz2 podman-98687ad4a603d5011db75a10e13599c5d241472d.zip |
Merge pull request #5552 from giuseppe/rootlessport-handle-sigpipe
rootlessport: handle SIGPIPE
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/rootlessport/rootlessport_linux.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pkg/rootlessport/rootlessport_linux.go b/pkg/rootlessport/rootlessport_linux.go index febfc2268..6ecd3cf98 100644 --- a/pkg/rootlessport/rootlessport_linux.go +++ b/pkg/rootlessport/rootlessport_linux.go @@ -19,6 +19,7 @@ import ( "io/ioutil" "os" "os/exec" + "os/signal" "syscall" "github.com/containernetworking/plugins/pkg/ns" @@ -101,6 +102,28 @@ func parent() error { return err } + sigC := make(chan os.Signal, 1) + signal.Notify(sigC, syscall.SIGPIPE) + defer func() { + // dummy signal to terminate the goroutine + sigC <- syscall.SIGKILL + }() + go func() { + defer func() { + signal.Stop(sigC) + close(sigC) + }() + + s := <-sigC + if s == syscall.SIGPIPE { + if f, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755); err == nil { + syscall.Dup2(int(f.Fd()), 1) // nolint:errcheck + syscall.Dup2(int(f.Fd()), 2) // nolint:errcheck + f.Close() + } + } + }() + // create the parent driver stateDir, err := ioutil.TempDir(cfg.TmpDir, "rootlessport") if err != nil { |