Sign in Join

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

Mailing lists / fpc-pascal / 2009-09

Linux program sometimes crashes with "EProcess : Failed to create pipes"

4 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

T. Guilleminot

Hi,

Have a Linux program that recently started to crash several times with such message :
An unhandled exception occurred at $080A4CB9 :
EProcess : Failed to create pipes
$080A4CB9
$080A4D3D
$080526E0
$08057C11
$08058809
$B7B082B6
$B7B07B88
$B7B0B0EB
$B7B0B5BA
$B7CF57D9
$0805AABD

This seems only occurs after a long running period of time. Considering error message and as it runs very often some OS processes I suspect TProcess. I use such procedure :

  Procedure Run_Command(Wait : boolean; TheCommand : ansistring); cdecl;
export;
  var
    AProcess: TProcess;
  Begin
    AProcess := TProcess.Create(nil);
    AProcess.CommandLine := TheCommand;
    if Wait = true then AProcess.Options := AProcess.Options +
[poWaitOnExit];
    AProcess.Execute;
    AProcess.Free;
  end;

I think I may hit some OS limits or I overload system. Does anyone know how to diagnose this further (why it fails...) and/or to fix this ?

Thanks
Tom

Jonas Maebe
to T. Guilleminot
T. Guilleminot wrote
I think I may hit some OS limits or I overload system. Does anyone know how to diagnose this further (why it fails...)

You can run strace on it to check whether it closes all file descriptors that are opened. You can also use the "lsof" utility to see all open file descriptors.

Jonas

Burkhard Carstens
to T. Guilleminot: Have a Linux program that recently started to crash several times with such message : An…
T. Guilleminot wrote 38 lines
Hi, Have a Linux program that recently started to crash several times with such message : An unhandled exception occurred at $080A4CB9 : EProcess : Failed to create pipes $080A4CB9 $080A4D3D $080526E0 $08057C11 $08058809 $B7B082B6 $B7B07B88 $B7B0B0EB $B7B0B5BA $B7CF57D9 $0805AABD This seems only occurs after a long running period of time. Considering error message and as it runs very often some OS processes I suspect TProcess. I use such procedure : Procedure Run_Command(Wait : boolean; TheCommand : ansistring); cdecl; export; var AProcess: TProcess; Begin AProcess := TProcess.Create(nil); AProcess.CommandLine := TheCommand; if Wait = true then AProcess.Options := AProcess.Options + [poWaitOnExit]; AProcess.Execute; AProcess.Free; end; I think I may hit some OS limits or I overload system. Does anyone know how to diagnose this further (why it fails...) and/or to fix this ?

Using this procedure with wait=false leaves you a zombie process. I.e. even, if "TehCommand" finished, the process isn't closed unless you call fpWaitPID (or better WaitOnExit) on it's pid. Not sure, but probably the zombie still holds the pipes and therefore you run out of handles and some point.

see also: http://mantis.freepascal.org/view.php?id=11797

regards
Burkhard

Funky Beast
to Burkhard Carstens
Burkhard Carstens wrote 54 lines
Am Donnerstag, 10. September 2009 11:01 schrieb T. Guilleminot: > Hi, > > Have a Linux program that recently started to crash several times > with such message : > An unhandled exception occurred at $080A4CB9 : > EProcess : Failed to create pipes > $080A4CB9 > $080A4D3D > $080526E0 > $08057C11 > $08058809 > $B7B082B6 > $B7B07B88 > $B7B0B0EB > $B7B0B5BA > $B7CF57D9 > $0805AABD > > This seems only occurs after a long running period of time. > Considering error message and as it runs very often some OS processes > I suspect TProcess. I use such procedure : > > Procedure Run_Command(Wait : boolean; TheCommand : ansistring); > cdecl; export; > var > AProcess: TProcess; > Begin > AProcess := TProcess.Create(nil); > AProcess.CommandLine := TheCommand; > if Wait = true then AProcess.Options := AProcess.Options + > [poWaitOnExit]; > AProcess.Execute; > AProcess.Free; > end; > > I think I may hit some OS limits or I overload system. > Does anyone know how to diagnose this further (why it fails...) > and/or to fix this ? Using this procedure with wait=false leaves you a zombie process. I.e. even, if "TehCommand" finished, the process isn't closed unless you call fpWaitPID (or better WaitOnExit) on it's pid. Not sure, but probably the zombie still holds the pipes and therefore you run out of handles and some point. see also: http://mantis.freepascal.org/view.php?id=11797 regards Burkhard _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Hi,

If you don't need to wait for the program, I have a work around that prevents zombies with the simple class I wrote below. Note that it works only on Linux. I wrote it in a class because I might add other signals to ignore later on as I travel on further on the multi-process route.

Usage: Create an instance of TIgnoreSignal on your process calling program, and call its DoIgnoreChildProc procedure at anywhere before you execute your external processes or when your program starts. Once executed, any external process/es signals are ignored from then on.

**********************************************************************************************
unit IgnoreSignal;
//This is a class to allow a main application who executes external child processes(programs)
//to ignore / let go of them after executing them. This is to prevent zombies, if the child
//misbehaves.
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, BaseUnix, Unix;
type
  { TIgnoreSignal }
  TIgnoreSignal = class
  public
   procedure DoIgnoreChildProc;
  end;
implementation

{ TIgnoreSignal }

procedure TIgnoreSignal.DoIgnoreChildProc;
var sigact: sigactionrec;
begin
 sigact.sa_flags := SA_NOCLDWAIT;
 FPSigaction(SIGCHLD, @sigact, nil);
end;
end.
**********************************************************************************************

HTH,
Funky Beast