|
From: <ob...@us...> - 2012-05-02 08:07:45
|
Revision: 3786
http://jcl.svn.sourceforge.net/jcl/?rev=3786&view=rev
Author: obones
Date: 2012-05-02 08:07:34 +0000 (Wed, 02 May 2012)
Log Message:
-----------
Always terminate the process, or else it will leave it dangling, with all its handles opened. This is especially important when one of the text handlers triggers and exception
Modified Paths:
--------------
trunk/jcl/source/common/JclSysUtils.pas
Modified: trunk/jcl/source/common/JclSysUtils.pas
===================================================================
--- trunk/jcl/source/common/JclSysUtils.pas 2012-04-30 07:54:26 UTC (rev 3785)
+++ trunk/jcl/source/common/JclSysUtils.pas 2012-05-02 08:07:34 UTC (rev 3786)
@@ -2932,7 +2932,6 @@
AbortPtr := @InternalAbort;
// init the array of events to wait for
ProcessEvent := TJclDispatcherObject.Attach(ProcessInfo.hProcess);
- ProcessInfo.hProcess := 0; // ProcessEvent now "owns" the handle
SetLength(WaitEvents, 2);
// add the process first
WaitEvents[0] := ProcessEvent;
@@ -3017,14 +3016,16 @@
CloseHandle(ErrorPipeInfo.PipeWrite);
if ProcessInfo.hThread <> 0 then
CloseHandle(ProcessInfo.hThread);
- if ProcessInfo.hProcess <> 0 then
- begin
- TerminateProcess(ProcessInfo.hProcess, Cardinal(ABORT_EXIT_CODE));
- WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
- GetExitCodeProcess(ProcessInfo.hProcess, Result);
+
+ // always terminate process, especially useful when an exception occured
+ // in one of the texthandler
+ TerminateProcess(ProcessInfo.hProcess, Cardinal(ABORT_EXIT_CODE));
+ WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
+ GetExitCodeProcess(ProcessInfo.hProcess, Result);
+ if Assigned(ProcessEvent) then
+ ProcessEvent.Free // this calls CloseHandle(ProcessInfo.hProcess)
+ else
CloseHandle(ProcessInfo.hProcess);
- end;
- ProcessEvent.Free; // this calls CloseHandle(ProcessInfo.hProcess)
OutPipeInfo.Event.Free;
ErrorPipeInfo.Event.Free;
end;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|