16inline auto call(
const std::vector<std::string>& args_array,
const std::vector<std::string>& environment_array = {}) -> call_result
21 std::vector<const char*> args;
22 std::vector<const char*> environment;
23 args.reserve(args_array.size());
24 for(
const auto& arg : args_array)
26 args.emplace_back(arg.c_str());
28 args.emplace_back(
nullptr);
31 for(
const auto& env : environment_array)
46 if(environment_array.empty())
58 result.out_output =
"Failed to create subprocess for " + args_array.front();
65 char out_buffer[1024];
66 char err_buffer[1024];
68 auto read_all_stdout = [&]()
73 out_buffer[bytes_read] =
'\0';
74 result.out_output += out_buffer;
78 auto read_all_stderr = [&]()
83 err_buffer[bytes_read] =
'\0';
84 result.err_output += err_buffer;
119inline auto call(
const std::string& process,
const std::vector<std::string>& args_array = {}) -> call_result
121 std::vector<std::string> merged{process};
122 merged.insert(merged.end(), args_array.begin(), args_array.end());
auto call(const std::vector< std::string > &args_array, const std::vector< std::string > &environment_array={}) -> call_result
@ environment
Environment reflection method.
subprocess_weak unsigned subprocess_read_stdout(struct subprocess_s *const process, char *const buffer, unsigned size)
Read the standard output from the child process.
@ subprocess_option_search_user_path
@ subprocess_option_inherit_environment
@ subprocess_option_combined_stdout_stderr
subprocess_weak int subprocess_join(struct subprocess_s *const process, int *const out_return_code)
Wait for a process to finish execution.
subprocess_weak unsigned subprocess_read_stderr(struct subprocess_s *const process, char *const buffer, unsigned size)
Read the standard error from the child process.
subprocess_weak int subprocess_destroy(struct subprocess_s *const process)
Destroy a previously created process.
subprocess_weak int subprocess_create(const char *const command_line[], int options, struct subprocess_s *const out_process)
Create a process.
subprocess_weak int subprocess_alive(struct subprocess_s *const process)
Returns if the subprocess is currently still alive and executing.
subprocess_weak int subprocess_create_ex(const char *const command_line[], int options, const char *const environment[], struct subprocess_s *const out_process)
Create a process (extended create).