Monday, June 25, 2007

How to catch kernel-signals in Kylix?


program TestSignals;

{$APPTYPE CONSOLE}

uses Libc;

var
bTerminate: Boolean;

procedure SignalProc(SigNum: Integer); cdecl;
begin
case SigNum of
SIGQUIT:
begin
WriteLn('signal SIGQUIT');
bTerminate := true;
end;
SIGUSR1: WriteLn('signal SIGUSR1');
else
WriteLn('not handled signal');
end;
signal(SigNum, SignalProc);
end;

begin
bTerminate := false;

signal(SIGQUIT, SignalProc);
signal(SIGUSR1, SignalProc);

repeat
sleep(1);
until bTerminate;
end.

No comments: