Код: Выделить всё
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// Function to execute a shell command and get the result
std::string exec(const std::string& cmd) {
std::array buffer;
std::string result;
std::unique_ptr pipe(popen(cmd.c_str(), "r"), pclose);
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
}
// Function to be executed by each thread
void threadFunction(const std::string& tty, std::atomic& running, int threadId) {
int messageCount = 0;
std::ofstream ttyStream(tty);
if (!ttyStream.is_open()) {
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/78785708/how-would-i-take-input-and-output-data-on-multiple-tmux-terminal-using-a-cpp-pro[/url]