Skip to content

Commit

Permalink
libcontainer: if close_range fails, fall back to the old way
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Phoenix <[email protected]>
  • Loading branch information
evanphx committed Jan 24, 2025
1 parent 111e8dc commit 33315a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libcontainer/utils/utils_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ func CloseExecFrom(minFd int) error {
// Use close_range(CLOSE_RANGE_CLOEXEC) if possible.
if haveCloseRangeCloexec() {
err := unix.CloseRange(uint(minFd), math.MaxInt32, unix.CLOSE_RANGE_CLOEXEC)
return os.NewSyscallError("close_range", err)
if err == nil {
return nil
}

logrus.Debugf("close_range failed, closing range one at a time (error: %v)", err)

// If close_range fails, we fall back to the standard loop.
}
// Otherwise, fall back to the standard loop.
return fdRangeFrom(minFd, unix.CloseOnExec)
Expand Down

0 comments on commit 33315a0

Please sign in to comment.