[fpc-pascal]signal handling under linux...

Adam Naumowicz adamn at math.uwb.edu.pl
Fri Jul 27 16:07:28 CEST 2001


On Fri, 27 Jul 2001, Gene Buckle wrote:

> Is there a known method for processing signals such as SIGTERM and
> SIGQUIT?  I need to be able to execute some code when either one of those
> signals are sent to my application.

To install your own signal handler use the Signal function in 'linux'
unit like that:

var NewSignal, OldSigInt : SignalHandler;

procedure CatchSignal(aSig : Integer);cdecl;
begin
  case aSig of
    SIGQUIT : do_something1;
    SIGTERM : do_something2;
  end;
end;

...

NewSignal:=SignalHandler(CatchSignal);
OldSigInt:=Signal(SIDQUIT,NewSignal);
OldSigInt:=Signal(SIGTERM,NewSignal);

Regards,
Adam Naumowicz

--------------------------------------
WWW: http://math.uwb.edu.pl/~adamn/
--------------------------------------





More information about the fpc-pascal mailing list