[fpc-pascal] ExitProc

Carsten Bager carsten at beas.dk
Thu Jun 29 13:51:29 CEST 2006


If I compile and run my example program and then press Crtl+C the 
program terminates. I would expect that it terminate by calling 
"CloseServer" procedure, but it dos not. If the program terminates 
normally (time runs out) the "CloseServer" procedure is called as 
expected.

Have I misunderstood something about the ExitProc.
   
Regards Carsten

program exitp;
Uses sysutils;    {System}


var
  ExitProcGem:pointer;

Procedure CloseServer;
Begin
  ExitProc:=ExitProcGem;
  WriteLn('Server closed.');
End;
begin
  ExitProcGem:=ExitProc;
  ExitProc:=@CloseServer;
  sleep(10000);
  WriteLn('--Close--');
end.




More information about the fpc-pascal mailing list