18 #ifndef RAUL_PROCESS_HPP
19 #define RAUL_PROCESS_HPP
25 #include <sys/resource.h>
26 #include <boost/utility.hpp>
43 static bool launch(
const std::string& command) {
44 const std::string executable = (command.find(
" ") != std::string::npos)
45 ? command.substr(0, command.find(
" "))
48 const std::string arguments = command.substr((command.find(
" ") + 1));
50 std::cerr <<
"Launching child process '" << executable <<
"' with arguments '"
51 << arguments <<
"'" << std::endl;
54 const int err = fork();
60 struct rlimit max_fds;
61 getrlimit(RLIMIT_NOFILE, &max_fds);
63 for (rlim_t fd = 3; fd < max_fds.rlim_cur; ++fd)
70 execlp(executable.c_str(), arguments.c_str(), NULL);
93 #endif // RAUL_PROCESS_HPP
static bool launch(const std::string &command)
Launch a sub process.
Definition: Process.hpp:43
A child process.
Definition: Process.hpp:35