Browse Source

Invalidate Handle, even if we don't close it. (it may be set, e.g. for iotNone)

Martin 1 year ago
parent
commit
2e9ceda11b
1 changed files with 5 additions and 2 deletions
  1. 5 2
      packages/fcl-process/src/processbody.inc

+ 5 - 2
packages/fcl-process/src/processbody.inc

@@ -1078,10 +1078,13 @@ var
   H : THandle;
 
 begin
-  if (FTheirHandleIOType=iotNone) or Not FHandleValid then
+  if Not FHandleValid then
      exit;
-  If not (CloseHandleOnExecute or aForceClose) then
+  If (FTheirHandleIOType=iotNone) or not (CloseHandleOnExecute or aForceClose) then
+    begin
+    FTheirHandle:=THandle(INVALID_HANDLE_VALUE);
      exit;
+    end;
   H:=ResolveProcessHandle;
   // Writeln(StdErr,GetProcessID,' : ',ProcessHandleType,' closing their handle ',IOType,': ',H);
   FTheirHandle:=THandle(INVALID_HANDLE_VALUE);