Cleanup and try to unify with the other code
This commit is contained in:
parent
4435bb091b
commit
f549a2bac8
@ -68,6 +68,15 @@ bool cmWin32ProcessExecution::Wait(int timeout)
|
|||||||
*/
|
*/
|
||||||
static void *_PyPopenProcs = NULL;
|
static void *_PyPopenProcs = NULL;
|
||||||
|
|
||||||
|
static bool IsWinNT()
|
||||||
|
//check if we're running NT
|
||||||
|
{
|
||||||
|
OSVERSIONINFO osv;
|
||||||
|
osv.dwOSVersionInfoSize = sizeof(osv);
|
||||||
|
GetVersionEx(&osv);
|
||||||
|
return (osv.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL RealPopenCreateProcess(const char *cmdstring,
|
static BOOL RealPopenCreateProcess(const char *cmdstring,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *szConsoleSpawn,
|
const char *szConsoleSpawn,
|
||||||
@ -209,7 +218,6 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
|
|||||||
CloseHandle(piProcInfo.hThread);
|
CloseHandle(piProcInfo.hThread);
|
||||||
/* Return process handle */
|
/* Return process handle */
|
||||||
*hProcess = piProcInfo.hProcess;
|
*hProcess = piProcInfo.hProcess;
|
||||||
//std::cout << "Process created..." << std::endl;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
win32_error("CreateProcess", s2);
|
win32_error("CreateProcess", s2);
|
||||||
@ -232,9 +240,22 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring,
|
|||||||
int fd1, fd2, fd3;
|
int fd1, fd2, fd3;
|
||||||
//FILE *f1, *f2, *f3;
|
//FILE *f1, *f2, *f3;
|
||||||
|
|
||||||
|
SECURITY_DESCRIPTOR sd;
|
||||||
|
if (IsWinNT())
|
||||||
|
//initialize security descriptor (Windows NT)
|
||||||
|
{
|
||||||
|
InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
|
||||||
|
SetSecurityDescriptorDacl(&sd, true, NULL, false);
|
||||||
|
saAttr.lpSecurityDescriptor = &sd;
|
||||||
|
|
||||||
|
}
|
||||||
|
else saAttr.lpSecurityDescriptor = NULL;
|
||||||
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||||
saAttr.bInheritHandle = TRUE;
|
saAttr.bInheritHandle = true;
|
||||||
saAttr.lpSecurityDescriptor = NULL;
|
|
||||||
|
//saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||||
|
//saAttr.bInheritHandle = TRUE;
|
||||||
|
//saAttr.lpSecurityDescriptor = NULL;
|
||||||
|
|
||||||
if (!CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
|
if (!CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
|
||||||
{
|
{
|
||||||
@ -512,22 +533,16 @@ bool cmWin32ProcessExecution::PrivateClose(int timeout)
|
|||||||
|
|
||||||
std::string output = "";
|
std::string output = "";
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
while(!done)
|
while(!done)
|
||||||
{
|
{
|
||||||
Sleep(10);
|
char buffer[1023]="";
|
||||||
|
int len = 0;
|
||||||
|
Sleep(1);
|
||||||
bool have_some = false;
|
bool have_some = false;
|
||||||
struct _stat fsout;
|
len = read(this->m_pStdErr, buffer, 1023);
|
||||||
struct _stat fserr;
|
if ( len > 0 )
|
||||||
int rout = _fstat(this->m_pStdOut, &fsout);
|
|
||||||
int rerr = _fstat(this->m_pStdErr, &fserr);
|
|
||||||
if ( rout && rerr )
|
|
||||||
{
|
{
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (fserr.st_size > 0)
|
|
||||||
{
|
|
||||||
char buffer[1023];
|
|
||||||
int len = read(this->m_pStdErr, buffer, 1023);
|
|
||||||
buffer[len] = 0;
|
buffer[len] = 0;
|
||||||
if ( this->m_Verbose )
|
if ( this->m_Verbose )
|
||||||
{
|
{
|
||||||
@ -536,10 +551,9 @@ bool cmWin32ProcessExecution::PrivateClose(int timeout)
|
|||||||
output += buffer;
|
output += buffer;
|
||||||
have_some = true;
|
have_some = true;
|
||||||
}
|
}
|
||||||
if (fsout.st_size > 0)
|
len = read(this->m_pStdOut, buffer, 1023);
|
||||||
|
if ( len > 0 )
|
||||||
{
|
{
|
||||||
char buffer[1023];
|
|
||||||
int len = read(this->m_pStdOut, buffer, 1023);
|
|
||||||
buffer[len] = 0;
|
buffer[len] = 0;
|
||||||
if ( this->m_Verbose )
|
if ( this->m_Verbose )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user