Files
universal-system-monitor/include/common.h
2018-12-12 17:57:59 +00:00

24 lines
477 B
C++

#pragma once
#include <vector>
#include <string>
#include <iostream>
#include <unistd.h>
std::vector<std::string> execcommand(std::string command) {
char buffer[128];
std::vector<std::string> result;
FILE* pipe = popen(command.c_str(), "r");
try {
while (fgets(buffer, sizeof buffer, pipe) != NULL) {
result.push_back(buffer);
}
} catch (...) {
pclose(pipe);
throw;
}
pclose(pipe);
return result;
}