[compiler-rt] [sanitizer] Make internal_close_range available on all POSIX platforms (PR #191971)
Paweł Bylica via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 10:20:42 PDT 2026
================
@@ -562,11 +562,10 @@ pid_t StartSubprocess(const char *program, const char *const argv[],
internal_close(stderr_fd);
}
-# if SANITIZER_FREEBSD
- internal_close_range(3, ~static_cast<fd_t>(0), 0);
-# else
- for (int fd = sysconf(_SC_OPEN_MAX); fd > 2; fd--) internal_close(fd);
-# endif
+ // Use close_range to avoid a slow loop when RLIMIT_NOFILE is high.
+ // Falls back to the loop if not available on this platform/kernel.
+ if (internal_close_range(3, ~static_cast<fd_t>(0), 0) != 0)
+ for (int fd = sysconf(_SC_OPEN_MAX); fd > 2; fd--) internal_close(fd);
----------------
chfast wrote:
So this has to preceded this PR?
https://github.com/llvm/llvm-project/pull/191971
More information about the llvm-commits
mailing list