Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-08

TProcess bug fix...

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tom Lisjac

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;

Reply by email

Michael Van Canneyt
to Tom Lisjac
Tom Lisjac wrote 11 lines
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.

I applied the patch. Thanks.

Michael.

Reply by email