Making 2+ processes run in non-blocking mode #56
-
Code reproc::options options;
options.nonblocking = true;
const char *sargv[] = { "ping", "localhost", "-n", "6", NULL };
std::tie(status, ec) = reproc::run(sargv, options);
std::cout << "status1: " << status << std::endl;
if (ec) {
std::cerr << ec.message() << std::endl;
}
const char *margv[] = { "cmake", "--help", NULL };
std::tie(status, ec) = reproc::run(margv, options);
std::cout << "status2: " << status << std::endl;
if (ec) {
std::cerr << ec.message() << std::endl;
} Unfortunately, the second Question
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The |
Beta Was this translation helpful? Give feedback.
The
reproc_poll
(orreproc::poll
in C++) should allow to implement this. If you check the C examples, there's a detailed example on how to usereproc_poll
to run multiple processes at once. Although it might be nice to write an extra function on top of it to run multiple processes concurrently and wait for them all to complete. We don't currently have that though. Note that the reproc++ API for poll is currently a bit bad until we can update reproc++ to minimum C++17 so we can usestd::optional
.