run.cpp 485 B

123456789101112131415161718192021222324
  1. #include <iostream>
  2. #include <reproc++/run.hpp>
  3. // Equivalent to reproc's run example but implemented using reproc++.
  4. int main(int argc, const char **argv)
  5. {
  6. (void) argc;
  7. int status = -1;
  8. std::error_code ec;
  9. reproc::options options;
  10. options.redirect.parent = true;
  11. options.deadline = reproc::milliseconds(5000);
  12. std::tie(status, ec) = reproc::run(argv + 1, options);
  13. if (ec) {
  14. std::cerr << ec.message() << std::endl;
  15. }
  16. return ec ? ec.value() : status;
  17. }