Skip to content
Permalink
Browse files

fix preserve-fds flag may cause runc hang

Signed-off-by: lifubang <lifubang@acmcoder.com>
  • Loading branch information...
lifubang committed Feb 28, 2019
1 parent f79e211 commit 7cb3cde1f49eae53fb8fff5012c0750a64eb928b
Showing with 6 additions and 1 deletion.
  1. +6 −1 utils_linux.go
@@ -3,7 +3,6 @@
package main

import (
"errors"
"fmt"
"net"
"os"
@@ -20,6 +19,7 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"

"github.com/coreos/go-systemd/activation"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"golang.org/x/sys/unix"
@@ -281,6 +281,11 @@ func (r *runner) run(config *specs.Process) (int, error) {
}
baseFd := 3 + len(process.ExtraFiles)
for i := baseFd; i < baseFd+r.preserveFDs; i++ {
_, err := os.Stat(fmt.Sprintf("/proc/self/fd/%d", i))
if err != nil {
r.destroy()
return -1, errors.Wrapf(err, "please check that preserved-fd %d (of %d) is present", i-baseFd, r.preserveFDs)
}
process.ExtraFiles = append(process.ExtraFiles, os.NewFile(uintptr(i), "PreserveFD:"+strconv.Itoa(i)))
}
rootuid, err := r.container.Config().HostRootUID()

0 comments on commit 7cb3cde

Please sign in to comment.
You can’t perform that action at this time.