signals

Adam Naumowicz adamn at math.uwb.edu.pl
Mon Aug 6 15:13:06 CEST 2001


On Mon, 6 Aug 2001, Ernst-Ludwig Bohnen wrote:

>
>
> On Mon, 6 Aug 2001, Adam Naumowicz wrote:
>
> > Hello,
> > I have two questions:
> > Is that the proper way to install a signal handler?
> >
> > program testsignal;
> > uses gpc;
> >
> > Procedure CatchSignal(sig:integer);
> > begin
> > case sig of
> >  2: writeln('Interrupted');
>                                 { <=====================}
>    otherwise {do nothing}       { this may help if sig is}
>                                 { not guaranteed to be 2}

Actually it doesn't make much sense as the InstallSignalHandler should
install a new install handler for a fixed signal (in my case for
SIGINT=2). I just put the case statement as if the CatchSignal was
prepared as a universal handler.

> > end;
> > end;
> >
> > var o:TSignalHandler;
> > b:boolean;
> > i:longint;
> > begin
> > InstallSignalHandler(SigInt,CatchSignal,true,true,o,b);
> > for i:=1 to 2000 do
> > writeln(i);
> > end.
> >
> > I intended it to be a SIGINT handler, but the Ctrl+C in the console
> > doesn't make the CatchSignal proc executed. I also don't know why I cannot
> > write SigInt as the case label - the compiler complains that
> > SigInt is not a constant or a variable of an ordinal type (but it is
> > declared as an integer in the GPC unit). Any ideas?

Regards,
Adam Naumowicz

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




More information about the Gpc mailing list