Программы на C++. Форум разработчиков
-
Anonymous
Многократный вызов и чтение вывода из подпроцесса
Сообщение
Anonymous »
Рассмотрим следующий код:
Код: Выделить всё
#include
#include
#include
#include
#include
int main() {
const char* command = "media-control get -h";
char output[4096];
for (int i = 0; i < 60; ++i) {
FILE* file = popen(command, "r");
int nbytes = read(fileno(file), output, sizeof(output));
pclose(file);
std::string stringoutput { output };
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79827883/repeatedly-calling-and-reading-output-from-subprocess[/url]
1763903323
Anonymous
Рассмотрим следующий код:
[code]#include
#include
#include
#include
#include
int main() {
const char* command = "media-control get -h";
char output[4096];
for (int i = 0; i < 60; ++i) {
FILE* file = popen(command, "r");
int nbytes = read(fileno(file), output, sizeof(output));
pclose(file);
std::string stringoutput { output };
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79827883/repeatedly-calling-and-reading-output-from-subprocess[/url]