mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 04:17:55 +01:00
porting rev.1998 from 1.4.4 (except ODBC, which will be done later, and SQLite, which was ported in rev.1999)
This commit is contained in:
@@ -129,18 +129,33 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
|
||||
fdmap[1] = outPipe ? outPipe->writeHandle() : 1;
|
||||
fdmap[2] = errPipe ? errPipe->writeHandle() : 2;
|
||||
|
||||
char* envPtr = 0;
|
||||
char** envPtr = 0;
|
||||
std::vector<char> envChars;
|
||||
std::vector<char*> envPtrs;
|
||||
if (!env.empty())
|
||||
{
|
||||
envChars = getEnvironmentVariablesBuffer(env);
|
||||
envPtr = &environmentChars[0];
|
||||
envPtrs.reserve(env.size() + 1);
|
||||
char* p = &envChars[0];
|
||||
while (*p)
|
||||
{
|
||||
envPtrs.push_back(p);
|
||||
while (*p) ++p;
|
||||
++p;
|
||||
}
|
||||
envPtrs.push_back(0);
|
||||
envPtr = &envPtrs[0];
|
||||
}
|
||||
|
||||
int pid = spawn(command.c_str(), 3, fdmap, &inherit, argv, envPtr);
|
||||
delete [] argv;
|
||||
if (pid == -1)
|
||||
throw SystemException("cannot spawn", command);
|
||||
|
||||
if (inPipe) inPipe->close(Pipe::CLOSE_READ);
|
||||
if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
|
||||
if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
|
||||
return new ProcessHandleImpl(pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user