diff --git a/src/Common/getCurrentProcessFDCount.cpp b/src/Common/getCurrentProcessFDCount.cpp index a78cc9fb1a0..b85256fabb4 100644 --- a/src/Common/getCurrentProcessFDCount.cpp +++ b/src/Common/getCurrentProcessFDCount.cpp @@ -9,6 +9,7 @@ int getCurrentProcessFDCount() { + int result = -1; #if defined(__linux__) || defined(__APPLE__) using namespace DB; @@ -21,6 +22,7 @@ int getCurrentProcessFDCount() try { + readIntText(result, command->out); command->wait(); } catch (...) @@ -31,25 +33,13 @@ int getCurrentProcessFDCount() try { + readIntText(result, command->out); command->wait(); } catch (...) { - return -1; } } - - WriteBufferFromOwnString out; - copyData(command->out, out); - - if (!out.str().empty()) - { - return parse(out.str()); - } - - return -1; -#else - return -1; #endif - + return result; } diff --git a/src/Common/getMaxFileDescriptorCount.cpp b/src/Common/getMaxFileDescriptorCount.cpp index 853a2c327c3..053ac0f812d 100644 --- a/src/Common/getMaxFileDescriptorCount.cpp +++ b/src/Common/getMaxFileDescriptorCount.cpp @@ -6,29 +6,21 @@ int getMaxFileDescriptorCount() { + int result = -1; #if defined(__linux__) || defined(__APPLE__) using namespace DB; auto command = ShellCommand::execute("ulimit -n"); try { + readIntText(result, command->out); command->wait(); } catch (...) { - return -1; } - WriteBufferFromOwnString out; - copyData(command->out, out); - - if (!out.str().empty()) - { - return parse(out.str()); - } - - return -1; -#else - return -1; #endif + + return result; }