fix preserve-fds flag may cause runc hang
Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
parent
f79e211b1d
commit
7cb3cde1f4
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue