mirror of
https://github.com/containers/podman.git
synced 2025-06-19 16:33:24 +08:00
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>
This commit is contained in:
@ -19,6 +19,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
@ -101,6 +102,28 @@ func parent() error {
|
|||||||
return err
|
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
|
// create the parent driver
|
||||||
stateDir, err := ioutil.TempDir(cfg.TmpDir, "rootlessport")
|
stateDir, err := ioutil.TempDir(cfg.TmpDir, "rootlessport")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user