diff --git a/code/nel/tools/pipeline/service/pipeline_process_impl.cpp b/code/nel/tools/pipeline/service/pipeline_process_impl.cpp index 95824e101..b6480fe60 100644 --- a/code/nel/tools/pipeline/service/pipeline_process_impl.cpp +++ b/code/nel/tools/pipeline/service/pipeline_process_impl.cpp @@ -30,6 +30,9 @@ // STL includes #include +#ifndef NL_OS_WINDOWS +# include +#endif // NeL includes #include @@ -177,12 +180,32 @@ void CPipelineProcessImpl::makePaths(const std::vector &outputPaths void CPipelineProcessImpl::runConsoleTool(const std::string &executablePath, const std::vector &arguments) { +#ifdef NL_OS_WINDOWS // FIXME: NOT SAFE FOR ARGUMENTS WITH SPACES std::stringstream ss; ss << executablePath; for (std::vector::const_iterator it = arguments.begin(), end = arguments.end(); it != end; ++it) ss << " " << *it; system(ss.str().c_str()); +#else + pid_t fork_id = fork(); + if (fork_id) + { + int exitCode; + while (wait(&exitCode) != fork_id) { /* ... */ } + } + else + { + std::vector argv; + argv.reserve(arguments.size() + 1); + argv.push_back(const_cast(executablePath.c_str())); + for (std::vector::const_iterator it = arguments.begin(), end = arguments.end(); it != end; ++it) + argv.push_back(const_cast((*it).c_str())); + argv.push_back(NULL); + execv(argv[0], &argv[0]); + exit(1); // failure + } +#endif } } /* namespace PIPELINE */