aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsay <say@yandex-team.com>2023-06-22 13:27:40 +0300
committersay <say@yandex-team.com>2023-06-22 13:27:40 +0300
commit8b6f16bdaac2d0e2ca9551f01414585a0e0951da (patch)
treec21df25919085c003e63d1b624e77b67086cb1e8
parent666c38adf68920e47b012694189ff22730fc6644 (diff)
downloadydb-8b6f16bdaac2d0e2ca9551f01414585a0e0951da.tar.gz
Revert commit rXXXXXX, Optimize CloseAllFdsOnExec for large MaxOpenFiles
-rw-r--r--util/system/shellcommand.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp
index 03c78b4d92..025a3ffd2f 100644
--- a/util/system/shellcommand.cpp
+++ b/util/system/shellcommand.cpp
@@ -687,22 +687,8 @@ void TShellCommand::TImpl::OnFork(TPipes& pipes, sigset_t oldmask, char* const*
}
if (Options_.CloseAllFdsOnExec) {
- int maxOpenFiles = NSystemInfo::MaxOpenFiles();
- TFsPath fdDir("/proc/self/fd");
- // For a big MaxOpenFiles value directory listing overhead is negligible against useless fcntl calls
- if (maxOpenFiles > 1024 && fdDir.IsDirectory()) {
- TVector<TString> files;
- fdDir.ListNames(files);
- for (const TString& f : files) {
- int fd;
- if (TryFromString(f, fd) && fd > STDERR_FILENO) {
- fcntl(fd, F_SETFD, FD_CLOEXEC);
- }
- }
- } else {
- for (int fd = maxOpenFiles; fd > STDERR_FILENO; --fd) {
- fcntl(fd, F_SETFD, FD_CLOEXEC);
- }
+ for (int fd = NSystemInfo::MaxOpenFiles(); fd > STDERR_FILENO; --fd) {
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
}
}