Explorar o código

* Prevent file descriptor leaks

Michaël Van Canneyt hai 1 ano
pai
achega
409abb8a43
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      packages/fcl-process/src/processbody.inc

+ 4 - 0
packages/fcl-process/src/processbody.inc

@@ -1069,7 +1069,10 @@ begin
   H:=ResolveProcessHandle;
   // Writeln(StdErr,GetProcessID,' : ',ProcessHandleType,' closing their handle ',IOType,': ',H);
   if H<>THandle(INVALID_HANDLE_VALUE) then
+    begin
     FileClose(H);
+    FTheirHandle:=THandle(INVALID_HANDLE_VALUE);
+    end;
 end;
 
 procedure TIODescriptor.PrepareHandles;
@@ -1133,6 +1136,7 @@ end;
 destructor TIODescriptor.Destroy;
 begin
   FreeAndNil(FStream);
+  ResetHandles;
   inherited Destroy;
 end;