Skip to content

Commit 33315a0

Browse files
committed
libcontainer: if close_range fails, fall back to the old way
Signed-off-by: Evan Phoenix <[email protected]>
1 parent 111e8dc commit 33315a0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libcontainer/utils/utils_unix.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ func CloseExecFrom(minFd int) error {
103103
// Use close_range(CLOSE_RANGE_CLOEXEC) if possible.
104104
if haveCloseRangeCloexec() {
105105
err := unix.CloseRange(uint(minFd), math.MaxInt32, unix.CLOSE_RANGE_CLOEXEC)
106-
return os.NewSyscallError("close_range", err)
106+
if err == nil {
107+
return nil
108+
}
109+
110+
logrus.Debugf("close_range failed, closing range one at a time (error: %v)", err)
111+
112+
// If close_range fails, we fall back to the standard loop.
107113
}
108114
// Otherwise, fall back to the standard loop.
109115
return fdRangeFrom(minFd, unix.CloseOnExec)

0 commit comments

Comments
 (0)