mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
Merge pull request #11269 from Luap99/rootlessport-flake
fix rootlessport flake
This commit is contained in:
@ -20,7 +20,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
@ -106,30 +105,6 @@ func parent() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|
||||||
}()
|
|
||||||
|
|
||||||
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:
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
socketDir := filepath.Join(cfg.TmpDir, "rp")
|
socketDir := filepath.Join(cfg.TmpDir, "rp")
|
||||||
err = os.MkdirAll(socketDir, 0700)
|
err = os.MkdirAll(socketDir, 0700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -251,8 +226,16 @@ outer:
|
|||||||
go serve(socket, driver)
|
go serve(socket, driver)
|
||||||
}
|
}
|
||||||
|
|
||||||
// write and close ReadyFD (convention is same as slirp4netns --ready-fd)
|
|
||||||
logrus.Info("ready")
|
logrus.Info("ready")
|
||||||
|
|
||||||
|
// https://github.com/containers/podman/issues/11248
|
||||||
|
// Copy /dev/null to stdout and stderr to prevent SIGPIPE errors
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
// write and close ReadyFD (convention is same as slirp4netns --ready-fd)
|
||||||
if _, err := readyW.Write([]byte("1")); err != nil {
|
if _, err := readyW.Write([]byte("1")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user