summaryrefslogtreecommitdiffstats
path: root/Source/cmWin32ProcessExecution.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2007-07-24 19:55:03 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2007-07-24 19:55:03 (GMT)
commit69b7ba3543be4ad55c08f617c21a229da45ebca0 (patch)
tree0a7e1a58da00627d2adcdb21f17b80120f1f3c3c /Source/cmWin32ProcessExecution.cxx
parentf89dac80fdb6eed1c5df88525ed825d878e39b73 (diff)
downloadCMake-69b7ba3543be4ad55c08f617c21a229da45ebca0.zip
CMake-69b7ba3543be4ad55c08f617c21a229da45ebca0.tar.gz
CMake-69b7ba3543be4ad55c08f617c21a229da45ebca0.tar.bz2
ENH: fix resource leak
Diffstat (limited to 'Source/cmWin32ProcessExecution.cxx')
-rw-r--r--Source/cmWin32ProcessExecution.cxx50
1 files changed, 44 insertions, 6 deletions
diff --git a/Source/cmWin32ProcessExecution.cxx b/Source/cmWin32ProcessExecution.cxx
index 27ec2e5..165bd21 100644
--- a/Source/cmWin32ProcessExecution.cxx
+++ b/Source/cmWin32ProcessExecution.cxx
@@ -142,14 +142,11 @@ bool cmWin32ProcessExecution::BorlandRunCommand(
if (!CreatePipe(&newstdin,&write_stdin,&sa,0))
//create stdin pipe
{
- std::cerr << "CreatePipe" << std::endl;
return false;
-
}
if (!CreatePipe(&read_stdout,&newstdout,&sa,0))
//create stdout pipe
{
- std::cerr << "CreatePipe" << std::endl;
CloseHandle(newstdin);
CloseHandle(write_stdin);
return false;
@@ -637,7 +634,21 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring,
this->hChildStdoutWr,
&hProcess, this->HideWindows,
this->Output))
+ {
+ if(fd1 >= 0)
+ {
+ close(fd1);
+ }
+ if(fd2 >= 0)
+ {
+ close(fd2);
+ }
+ if(fd3 >= 0)
+ {
+ close(fd3);
+ }
return 0;
+ }
}
else
{
@@ -649,7 +660,21 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring,
this->hChildStderrWr,
&hProcess, this->HideWindows,
this->Output))
+ {
+ if(fd1 >= 0)
+ {
+ close(fd1);
+ }
+ if(fd2 >= 0)
+ {
+ close(fd2);
+ }
+ if(fd3 >= 0)
+ {
+ close(fd3);
+ }
return 0;
+ }
}
/*
@@ -672,17 +697,14 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring,
this->ProcessHandle = hProcess;
if ( fd1 >= 0 )
{
- // this->StdIn = f1;
this->pStdIn = fd1;
}
if ( fd2 >= 0 )
{
- // this->StdOut = f2;
this->pStdOut = fd2;
}
if ( fd3 >= 0 )
{
- // this->StdErr = f3;
this->pStdErr = fd3;
}
@@ -691,6 +713,22 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring,
bool cmWin32ProcessExecution::CloseHandles()
{
+ if(this->pStdErr != -1 )
+ {
+ _close(this->pStdErr);
+ this->pStdErr = -1;
+ }
+ if(this->pStdIn != -1 )
+ {
+ _close(this->pStdIn);
+ this->pStdIn = -1;
+ }
+ if(this->pStdOut != -1 )
+ {
+ _close(this->pStdOut);
+ this->pStdOut = -1;
+ }
+
bool ret = true;
if (this->hChildStdinRd && !CloseHandle(this->hChildStdinRd))
{