fix unic cmd

This commit is contained in:
chatlanin
2022-07-24 12:06:20 +03:00
parent e7d35b0e1d
commit b746cdbe8c

View File

@@ -46,16 +46,14 @@ namespace hack::utils
}
}
inline std::string exec(const std::string& cmd)
inline std::string unix_cmd(const std::string& cmd)
{
std::string result;
std::array<char, 128> buffer;
std::array<char, 1024> buffer;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
if (!pipe)
{
throw std::runtime_error("bash cmd failed");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
{