Sign in Join
FPDoc Onlineexperiment

FpSignal function

In unit BaseUnix

Install signal handler (deprecated).

Declaration

pascal
function FpSignal(signum: LongInt; Handler: signalhandler)
: signalhandler

Description

FPSignal installs a new signal handler (specified by Handler) for signal SigNum.

This call has a subset of the functionality provided by the FpSigAction call. The return value for FpSignal is the old signal handler, or nil on error.

Errors

Extended error information can be retrieved using fpGetErrno.

SIG_ERR
An error occurred.

See also

Example: ex58

pascal
Program example58;

{ Program to demonstrate the Signal function.}

{
do a kill -USR1 pid from another terminal to see what happens.
replace pid with the real pid of this program.
You can get this pid by running 'ps'.
}

uses BaseUnix;

Procedure DoSig(sig : cint);cdecl;

begin
   writeln('Receiving signal: ',sig);
end;

begin
   if fpSignal(SigUsr1,SignalHandler(@DoSig))=signalhandler(SIG_ERR) then
     begin
     writeln('Error: ',fpGetErrno,'.');
     halt(1);
     end;
   Writeln ('Send USR1 signal or press <ENTER> to exit');
   readln;
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.