Sign in Join
FPDoc Onlineexperiment

FpAlarm function

In unit BaseUnix

Schedule an alarm signal to be delivered.

Declaration

pascal
function FpAlarm(seconds: cuint): cuint

Description

FpAlarm schedules an alarm signal to be delivered to your process in Seconds seconds. When Seconds seconds have elapsed, the system will send a SIGALRM signal to the current process. If Seconds is zero, then no new alarm will be set. Whatever the value of Seconds, any previous alarm is cancelled.

The function returns the number of seconds till the previously scheduled alarm was due to be delivered, or zero if there was none. A negative value indicates an error.

See also

Example: ex59

pascal
Program Example59;

{ Program to demonstrate the Alarm function. }

Uses BaseUnix;

Procedure AlarmHandler(Sig : cint);cdecl;

begin
  Writeln ('Got to alarm handler');
end;

begin
  Writeln('Setting alarm handler');
  fpSignal(SIGALRM,SignalHandler(@AlarmHandler));
  Writeln ('Scheduling Alarm in 10 seconds');
  fpAlarm(10);
  Writeln ('Pausing');
  fpPause;
  Writeln ('Pause returned');
end.

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