Build an execvp-compatible argv array from a vector of strings.
| 66 | |
| 67 | /// Build an execvp-compatible argv array from a vector of strings. |
| 68 | std::vector<char *> buildArgv(const std::vector<std::string> & args) |
| 69 | { |
| 70 | std::vector<char *> argv; |
| 71 | argv.reserve(args.size() + 1); |
| 72 | for (const auto & a : args) |
| 73 | argv.push_back(const_cast<char *>(a.c_str())); // NOLINT(cppcoreguidelines-pro-type-const-cast) |
| 74 | argv.push_back(nullptr); |
| 75 | return argv; |
| 76 | } |
| 77 | |
| 78 | /// Run a command and wait for it. Returns the exit code (or -1 on error). |
| 79 | int runCommand(const std::vector<std::string> & args) |
no test coverage detected