From 45cd53583982f0f0f41ce57a032a0f6c15fbf885 Mon Sep 17 00:00:00 2001 From: alesapin Date: Wed, 17 Nov 2021 15:44:07 +0300 Subject: [PATCH] Fix my own wrong command usage --- src/Common/getCurrentProcessFDCount.cpp | 18 ++++-------------- src/Common/getMaxFileDescriptorCount.cpp | 16 ++++------------ 2 files changed, 8 insertions(+), 26 deletions(-) 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; }