summaryrefslogtreecommitdiff
path: root/pkg/rootlessport/rootlessport_linux.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2020-03-19 15:27:06 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2020-03-19 15:59:30 +0100
commitbebc9d81456cab242c7effb64d9146e9f92f3e34 (patch)
tree546d81a8fe0931bf772afea57ac0140ed6583b77 /pkg/rootlessport/rootlessport_linux.go
parente87fe4dbbbc55be42d7a31f5415f55d2ff99f81b (diff)
downloadpodman-bebc9d81456cab242c7effb64d9146e9f92f3e34.tar.gz
podman-bebc9d81456cab242c7effb64d9146e9f92f3e34.tar.bz2
podman-bebc9d81456cab242c7effb64d9146e9f92f3e34.zip
rootlessport: handle SIGPIPE
when a sigpipe is received the stdout/stderr pipe was closed, so reopen them with /dev/null. Closes: https://github.com/containers/libpod/issues/5541 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/rootlessport/rootlessport_linux.go')
-rw-r--r--pkg/rootlessport/rootlessport_linux.go23
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 {