fix unic cmd
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user