[fpc-pascal] ExitProc

Tomas Hajny XHajT03 at mbox.vol.cz
Thu Jun 29 19:00:57 CEST 2006


Michael Van Canneyt wrote:
> On Thu, 29 Jun 2006, Jonas Maebe wrote:
>> On 29 jun 2006, at 13:51, Carsten Bager wrote:
>>
>>> 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.
>>
>> ExitProc is only called if your program exits via the RTL. This is the
>> case
>> when the program exits normally, or when a run time error or unhandled
>> exception occurs.
>>
>> ctrl-c is not caught by the FPC RTL. This means it is handled by the
>> operating system, and the default action of the operating system is to
>> simply
>> terminate the process. The FPC RTL therefore does not get any chance to
>> call
>> your exitproc.
>>
>> I don't know whether there's a platform-independent way in the RTL to
>> turn on
>> the catching of ctrl-c (and converting it to an exception or run time
>> error).
>
> Not that I am aware of...

Well, unit Crt should allow it if implemented properly (i.e. compatible to
TP/BP - at least IIRC)... ;-) Not that we'd have such an implementation at
the moment, though.

Tomas




More information about the fpc-pascal mailing list