Browse Source

Remember the IOType at time of handle creation (and before calling user events). User may reuse the instance and change it, then CloseTheirHandles needs to know.

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

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

@@ -57,6 +57,7 @@ Type
      FPipeBufferSize: cardinal;
      FPipeBufferSize: cardinal;
      FProcess: TProcess;
      FProcess: TProcess;
      FTheirHandle : THandle;
      FTheirHandle : THandle;
+     FTheirHandleIOType: TIOType;
      FHandleValid : Boolean;
      FHandleValid : Boolean;
      FStream : THandleStream;
      FStream : THandleStream;
      FOurHandle : THandle;
      FOurHandle : THandle;
@@ -1043,7 +1044,7 @@ end;
 
 
 function TIODescriptor.ResolveStream: THandleStream;
 function TIODescriptor.ResolveStream: THandleStream;
 begin
 begin
-  if (FStream=Nil) and (FHandleValid) and (IOType=iotPipe) then
+  if (FStream=Nil) and (FHandleValid) and (FTheirHandleIOType=iotPipe) then
     begin
     begin
     // Writeln(ProcessHandleType,' creating stream for stream ',IOType,': ',OurHandle);
     // Writeln(ProcessHandleType,' creating stream for stream ',IOType,': ',OurHandle);
     Case FHandleType of
     Case FHandleType of
@@ -1077,7 +1078,7 @@ var
   H : THandle;
   H : THandle;
 
 
 begin
 begin
-  if (IOType=iotNone) or Not FHandleValid then
+  if (FTheirHandleIOType=iotNone) or Not FHandleValid then
      exit;
      exit;
   If not (CloseHandleOnExecute or aForceClose) then
   If not (CloseHandleOnExecute or aForceClose) then
      exit;
      exit;
@@ -1123,6 +1124,7 @@ var
 begin
 begin
   if not FHandleValid then
   if not FHandleValid then
     begin
     begin
+    FTheirHandleIOType := IOType;
     FOurHandle:=THAndle(INVALID_HANDLE_VALUE);
     FOurHandle:=THAndle(INVALID_HANDLE_VALUE);
     Case IOType of
     Case IOType of
       iotNone : H:=CreateStandardHandle;
       iotNone : H:=CreateStandardHandle;