diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2007-07-24 14:05:31 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2007-07-24 14:05:31 (GMT) |
commit | 4ae802d9c19d1f021970215d992b6aebc4165ec8 (patch) | |
tree | f579708f14358e92cb88ab6f97d78cc77c221525 /Source/kwsys/ProcessWin32.c | |
parent | 8a6e2bb81d9ea372d873aa4f13edbc36d3a7826a (diff) | |
download | CMake-4ae802d9c19d1f021970215d992b6aebc4165ec8.zip CMake-4ae802d9c19d1f021970215d992b6aebc4165ec8.tar.gz CMake-4ae802d9c19d1f021970215d992b6aebc4165ec8.tar.bz2 |
ENH: fix resource leak
Diffstat (limited to 'Source/kwsys/ProcessWin32.c')
-rw-r--r-- | Source/kwsys/ProcessWin32.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index 6325a7b..2654a73 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -1453,7 +1453,6 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout) void kwsysProcess_Kill(kwsysProcess* cp) { int i; - /* Make sure we are executing a process. */ if(!cp || cp->State != kwsysProcess_State_Executing || cp->TimeoutExpired || cp->Killed) @@ -1485,7 +1484,10 @@ void kwsysProcess_Kill(kwsysProcess* cp) /* Not Windows 9x. Just terminate the children. */ for(i=0; i < cp->NumberOfCommands; ++i) { - kwsysProcessKillTree(cp->ProcessInformation[i].dwProcessId); + kwsysProcessKillTree(cp->ProcessInformation[i].dwProcessId); + // close the handle if we kill it + kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hThread); + kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hProcess); } } @@ -1851,7 +1853,6 @@ int kwsysProcessCreate(kwsysProcess* cp, int index, r = CreateProcess(0, realCommand, 0, 0, TRUE, cp->Win9x? 0 : CREATE_SUSPENDED, 0, 0, &si->StartupInfo, &cp->ProcessInformation[index]); - if(cp->Win9x) { /* Free memory. */ @@ -2114,7 +2115,6 @@ void kwsysProcessCleanupHandleSafe(PHANDLE h, DWORD nStdHandle) void kwsysProcessCleanup(kwsysProcess* cp, int error) { int i; - /* If this is an error case, report the error. */ if(error) { @@ -2861,6 +2861,7 @@ static void kwsysProcessKill(DWORD pid) { TerminateProcess(h, 255); WaitForSingleObject(h, INFINITE); + CloseHandle(h); } } |