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:
Aleksandar Fabijanic
2012-09-05 02:43:06 +00:00
parent 86bafbb27e
commit a221b14522
17 changed files with 224 additions and 48 deletions

View File

@@ -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
{