MCPcopy Create free account
hub / github.com/ashvardanian/less_slow.cpp / execute_system_call

Function execute_system_call

less_slow.cpp:6622–6630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6620auto to_microseconds(auto duration) { return std::chrono::duration_cast<std::chrono::microseconds>(duration); }
6621
6622std::string execute_system_call(std::string const &command) {
6623 std::array<char, 1024> buffer {};
6624 std::string result;
6625 if (FILE *pipe = popen(command.c_str(), "r")) {
6626 while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe)) result += buffer.data();
6627 pclose(pipe);
6628 }
6629 return result;
6630}
6631
6632std::string raise_system_error(std::string const &message) {
6633 std::string error_message = message + ": " + std::strerror(errno) + " (" + std::to_string(errno) + ")";

Callers 1

fetch_public_ipFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected