#include #include #include #include #include #include int getMaxFileDescriptorCount() { namespace fs = std::filesystem; int result = -1; #if defined(OS_LINUX) || defined(OS_DARWIN) using namespace DB; if (fs::exists("/proc/sys/fs/file-max")) { ReadBufferFromFile reader("/proc/sys/fs/file-max"); readIntText(result, reader); } else { auto command = ShellCommand::execute("ulimit -n"); try { readIntText(result, command->out); command->wait(); } catch (...) { } } #endif return result; }