Cleanup and try to unify with the other code

This commit is contained in:
Andy Cedilnik 2002-10-02 17:16:56 -04:00
parent 4435bb091b
commit f549a2bac8
1 changed files with 208 additions and 194 deletions

View File

@ -68,6 +68,15 @@ bool cmWin32ProcessExecution::Wait(int timeout)
*/
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,
const char *path,
const char *szConsoleSpawn,
@ -209,7 +218,6 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
CloseHandle(piProcInfo.hThread);
/* Return process handle */
*hProcess = piProcInfo.hProcess;
//std::cout << "Process created..." << std::endl;
return TRUE;
}
win32_error("CreateProcess", s2);
@ -232,9 +240,22 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring,
int fd1, fd2, fd3;
//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.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
saAttr.bInheritHandle = true;
//saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
//saAttr.bInheritHandle = TRUE;
//saAttr.lpSecurityDescriptor = NULL;
if (!CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
{
@ -512,22 +533,16 @@ bool cmWin32ProcessExecution::PrivateClose(int timeout)
std::string output = "";
bool done = false;
while(!done)
{
Sleep(10);
char buffer[1023]="";
int len = 0;
Sleep(1);
bool have_some = false;
struct _stat fsout;
struct _stat fserr;
int rout = _fstat(this->m_pStdOut, &fsout);
int rerr = _fstat(this->m_pStdErr, &fserr);
if ( rout && rerr )
len = read(this->m_pStdErr, buffer, 1023);
if ( len > 0 )
{
break;
}
if (fserr.st_size > 0)
{
char buffer[1023];
int len = read(this->m_pStdErr, buffer, 1023);
buffer[len] = 0;
if ( this->m_Verbose )
{
@ -536,10 +551,9 @@ bool cmWin32ProcessExecution::PrivateClose(int timeout)
output += buffer;
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;
if ( this->m_Verbose )
{