mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 10:52:30 +00:00
1a0b5f33b3
cmake/target.cmake defines macros for the supported platforms, this commit changes predefined system macros to our own macros. __linux__ --> OS_LINUX __APPLE__ --> OS_DARWIN __FreeBSD__ --> OS_FREEBSD
37 lines
775 B
C++
37 lines
775 B
C++
#include <IO/ReadHelpers.h>
|
|
#include <IO/WriteBufferFromString.h>
|
|
#include <IO/ReadBufferFromFile.h>
|
|
#include <Common/ShellCommand.h>
|
|
#include <Common/getMaxFileDescriptorCount.h>
|
|
#include <filesystem>
|
|
|
|
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;
|
|
}
|