From f9189c8fae73556fd70bd9a5fada72a19560bc77 Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 19 Mar 2024 17:38:14 +0100 Subject: [PATCH] FpDebug, Linux: Fix leaked handle (cherry picked from commit 5c5e12448dddbd8f01207d897d1787c9f076b621) --- components/fpdebug/fpdbglinuxclasses.pas | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/fpdebug/fpdbglinuxclasses.pas b/components/fpdebug/fpdbglinuxclasses.pas index c77138e6df..befa0a2f47 100644 --- a/components/fpdebug/fpdbglinuxclasses.pas +++ b/components/fpdebug/fpdbglinuxclasses.pas @@ -1148,6 +1148,11 @@ destructor TDbgLinuxProcess.Destroy; begin FProcProcess.Free; FPostponedSignals.Free; + + if FMasterPtyFd>-1 then + FpClose(FMasterPtyFd); + FMasterPtyFd:=-1; + inherited Destroy; end; @@ -1160,6 +1165,9 @@ var AnExecutabeFilename: string; begin Result := false; + if FMasterPtyFd>-1 then + FpClose(FMasterPtyFd); + FMasterPtyFd:=-1; AnExecutabeFilename:=ExcludeTrailingPathDelimiter(Name); if DirectoryExists(AnExecutabeFilename) then @@ -1213,6 +1221,7 @@ begin FpClose(GSlavePTyFd); if AMasterPtyFd>-1 then FpClose(AMasterPtyFd); + FMasterPtyFd:=-1; end; end; end; @@ -1464,7 +1473,6 @@ end; function TDbgLinuxProcess.Detach(AProcess: TDbgProcess; AThread: TDbgThread): boolean; begin RemoveAllBreakPoints; - fpPTrace(PTRACE_DETACH, AThread.ID, nil, pointer(TDbgLinuxThread(AThread).FExceptionSignal)); Result := True; end;