[fpc-pascal] how to use signals in freepascal?

Michael Van Canneyt michael at freepascal.org
Mon Mar 16 17:23:29 CET 2015



On Mon, 16 Mar 2015, Xiangrong Fang wrote:

> Hi All,
> 
> I have some questions regarding event and signals:
> 
> 1) RTLEventWaitFor
> 
> can a program waiting for an RTLEvent be notified by an RTLEventSet from ANOTHER process?
> 
> 2) Unix Signals
> 
> I see HookSignal() in the sysutils documentation, but there is nothing said on how to use it. Is it used to write my own signal handler on Linux?  Could anyone give a sample
> program? 

You should not use this in fact, it is meant for internal use.

To write a signal handler on unix, see

http://www.freepascal.org/docs-html/rtl/baseunix/fpsigaction.html

there is an example.

> 
> Also, is there a list of defined RtlSigNums?

No. The list of unix signals is well-known.

> 
> 3) Unix-style Signals on Windows
> 
> If possible, I would like to have cross platform signal handling in my app. I found this: 
> 
> https://github.com/graemeg/freepascal/blob/master/rtl/win32/signals.pp
> 
> Does it mean that if I "uses signals", I will have same capability on both linux and windows?

No. Signals work very different on window and Linux. 
They are similar concepts, but the implementation differs wildly.

To my knowledge, there is no cross-platform implementation of signals in FPC.

Michael.


More information about the fpc-pascal mailing list