From 122dfbd2ce9895087a4ae7ab0259c12bf857f313 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 15 Nov 2018 22:42:41 +0000 Subject: [PATCH] FpDebug: Windows, fix leaking filehandles / more (temp) fixes for not processing forked children git-svn-id: trunk@59552 - --- components/fpdebug/fpdbgwinclasses.pas | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/components/fpdebug/fpdbgwinclasses.pas b/components/fpdebug/fpdbgwinclasses.pas index 2e88234ff9..1f851abf9b 100644 --- a/components/fpdebug/fpdbgwinclasses.pas +++ b/components/fpdebug/fpdbgwinclasses.pas @@ -70,6 +70,7 @@ type function GetInstructionPointerRegisterValue: TDbgPtr; override; function GetStackBasePointerRegisterValue: TDbgPtr; override; function GetStackPointerRegisterValue: TDbgPtr; override; + property Process; end; @@ -823,9 +824,19 @@ begin end; CREATE_PROCESS_DEBUG_EVENT: begin //DumpEvent('CREATE_PROCESS_DEBUG_EVENT'); - StartProcess(MDebugEvent.dwThreadId, MDebugEvent.CreateProcessInfo); - FJustStarted := true; - result := deCreateProcess; + if MDebugEvent.dwProcessId = TDbgWinThread(AThread).Process.ProcessID then begin; + //main process + StartProcess(MDebugEvent.dwThreadId, MDebugEvent.CreateProcessInfo); // hfile will be closed by TDbgImageLoader + FJustStarted := true; + result := deCreateProcess; + end + else begin + //child process: ignore + // we currently do not use the file handle => close it + if MDebugEvent.CreateProcessInfo.hFile <> 0 then + CloseHandle(MDebugEvent.CreateProcessInfo.hFile); + result := deInternalContinue; + end; end; EXIT_THREAD_DEBUG_EVENT: begin //DumpEvent('EXIT_THREAD_DEBUG_EVENT');