Ubuntu doens't have a CPU governor.

This commit is contained in:
Robin Davies
2024-11-11 19:31:43 -05:00
parent bd994031bd
commit 64062fbbd7
17 changed files with 161 additions and 88 deletions
+6 -2
View File
@@ -14,6 +14,7 @@
#include "TemporaryFile.hpp"
#include "json_variant.hpp"
#include "GithubResponseHeaders.hpp"
#include "Finally.hpp"
using namespace std;
using namespace pipedal;
@@ -37,12 +38,15 @@ std::string psystem(const std::string &command)
std::string cmdRedirected = command + " 2>&1";
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmdRedirected.c_str(), "r"), pclose);
FILE *pipe = popen(cmdRedirected.c_str(), "r");
if (!pipe)
{
throw std::runtime_error("popen() failed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
Finally ([pipe]() {
pclose(pipe);
});
while (fgets(buffer.data(), buffer.size(), pipe) != nullptr)
{
result += buffer.data();
}