34 const std::vector<std::string>& argv,
35 const std::map<std::string, std::string>& env,
38 std::function<void()> null_function = [](){};
39 return exec(fn, argv, env, flags, null_function);
43 const std::vector<std::string>& argv,
44 const std::map<std::string, std::string>& env,
46 const std::function<
void()>& child_setup)
50 char** it;
char** pargv;
char** penv;
51 it = pargv =
new char*[argv.size()+2];
52 *it = ::strdup(fn.c_str());
54 for (
auto element : argv)
56 *it = ::strdup(element.c_str());
61 it = penv =
new char*[env.size()+1];
64 *it = ::strdup((pair.first +
"=" + pair.second).c_str());
Status
The Status enum wrap's the posix exit status.
StandardStream
The StandardStream enum wraps the POSIX standard streams.
CORE_POSIX_DLL_PUBLIC ChildProcess fork(const std::function< posix::exit::Status()> &main, const StandardStream &flags)
fork forks a new process and executes the provided main function in the newly forked process...
CORE_POSIX_DLL_PUBLIC ChildProcess exec(const std::string &fn, const std::vector< std::string > &argv, const std::map< std::string, std::string > &env, const StandardStream &flags)
exec execve's the executable with the provided arguments and environment.
The Process class models a child process of this process.