[lazarus] TProcess bug fix...

Tom Lisjac netdxr at adelphia.net
Tue Aug 12 07:30:18 EDT 2003



This is a fix for FCL bug 2559 where TProcess crashes with a "cannot
create pipe" error after about 300 calls.  I'm not subscribed to any of
the compiler lists and since TProcess is in the Lazarus system palette,
I thought I'd post it here.

The problem appears to be caused by 6 file handles being opened at the
start of the execute procedure... but only 3 are closed at the end. I
don't know if this is an optimal fix but the following cleans up any
open handles along with the streams during the initialization of
execute. It tested ok to 50K iterations.

-Tom

------------------------------------------------------------
Process.pp

Procedure TProcess.FreeStreams;
var FreedStreams: TList;

  procedure FreeStream(var AnObject: THandleStream); // was Tobject  
    begin
      if FreedStreams.IndexOf(AnObject)<0 then
        begin
        if Assigned(AnObject) then FileClose(AnObject.Handle); // added
        FreedStreams.Add(AnObject);
        AnObject.Free;
        end;
     AnObject:=nil;
    end;







More information about the Lazarus mailing list