Fix hang when `path` doesn't exist

I'm not sure if this is an OS-specific issue, but on CentOS 8, if `path`
doesn't exist, this hangs while waiting to read from this socket, even
though the socket is closed by the `reexec_in_user_namespace`.  Switching
to a pipe fixes the problem, and pipes shouldn't be an issue since this is
Linux-specific code.

Signed-off-by: Jonathan Dieter <jonathan.dieter@spearline.com>
This commit is contained in:
Jonathan Dieter 2020-08-11 15:51:16 +01:00
parent a90ae00df1
commit ec231973d8
1 changed files with 1 additions and 3 deletions

View File

@ -389,14 +389,12 @@ func TryJoinFromFilePaths(pausePidPath string, needNewNamespace bool, paths []st
lastErr = nil
break
} else {
fds, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_DGRAM, 0)
r, w, err := os.Pipe()
if err != nil {
lastErr = err
continue
}
r, w := os.NewFile(uintptr(fds[0]), "read file"), os.NewFile(uintptr(fds[1]), "write file")
defer errorhandling.CloseQuiet(r)
if _, _, err := becomeRootInUserNS("", path, w); err != nil {