Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-03

how to use signals in freepascal?

12 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Xiangrong Fang

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?

Also, is there a list of defined RtlSigNums?

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?

Thanks!

Xiangrong

Michael Van Canneyt
to Xiangrong Fang: I have some questions regarding event and signals: 1) RTLEventWaitFor can a program…
Xiangrong Fang wrote 12 lines
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.

Show quoted text 8 lines
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.

Xiangrong Fang
to Michael Van Canneyt
Show quoted text 8 lines
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.

​I tried example57, it worked, but I still do not know some peculiar behaviors in it​. I will ask later, after some investigations.

However, what is HookSignal for? How to use it? Or it is just a "stub" and not functional yet?

Thanks!

Michael Van Canneyt
to Xiangrong Fang
Xiangrong Fang wrote 12 lines
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. ​I tried example57, it worked, but I still do not know some peculiar behaviors in it​. I will ask later, after some investigations. However, what is HookSignal for? How to use it? Or it is just a "stub" and not functional yet?

It exists only for Kylix compatibility. I do not recommend it's use.

Michael.

Michael Schnell
to Michael Schnell

BTW.: I have done a seemingly working platform independent draft of an "active no-GUI Application" for Lazarus that allows to create "Applications" with TTimer and TThread.Synchronize() / TThread.Queue() without needing to link to a GUI for thinks that otherwise might suggest the use of Signals or Messages.

-Michael

Xiangrong Fang
to Michael Schnell: As there are similar concepts implemented in fpc and Lazarus in a cross-platform manner,…

2015-03-17 16:28 GMT+08:00 Michael Schnell :

Show quoted text 6 lines
As there are similar concepts implemented in fpc and Lazarus in a cross-platform manner, could you give the reason why you want too use platform-specific (low level) concepts like Unix-Signals (or Windows messages) ? (I don't doubt there are in some special projects.) Actually, I do *not* insist on using unix signals in a cross-platform way.

I just need a simple IPC mechanism, without the hassle of e.g. a socket server.​

Michael Schnell
to Xiangrong Fang
Xiangrong Fang wrote
I just need a simple IPC mechanism, without the hassle of e.g. a socket server.​

IPC between applications or within an application ?

If between application are both don in fpc and under your control ?

Lazarus or pure fpc ?

-Michael

Michael Van Canneyt
to Xiangrong Fang: 2015-03-17 16:28 GMT+08:00 Michael Schnell : I just need a simple IPC mechanism, without…
Xiangrong Fang wrote 5 lines
2015-03-17 16:28 GMT+08:00 Michael Schnell : As there are similar concepts implemented in fpc and Lazarus in a cross-platform manner, could you give the reason why you want too use platform-specific (low level) concepts like Unix-Signals (or Windows messages) ? (I don't doubt there are in some special projects.) Actually, I do *not* insist on using unix signals in a cross-platform way. I just need a simple IPC mechanism, without the hassle of e.g. a socket server.​

Then the simpleipc unit is for you. It does just that.

Michael.