xSignal Plugin

Hello,

For a console app I needed to reload preferences on the fly (i.e without restarting it) by sending a command thru a shell script. The idea was to send a signal to the application. There is one example provided with Xojo distribution but I think it is unsafe as the method call back directly Xojo code. This is why I wrote a little plugin to do that. It is compiled for Mac OS x86-64, Mac ARM, Raspberry, Linux x86 & x86-64 but not tested on Linux x86 nor Mac M1 as I don’t own a such hardware.

This plugin handle only SIGHUP, SIGUSR1 & SIGUSR2. Any others values will make application to quit.
Provided are the plugin itself a Xojo example and a little shell script but no documentation as I think it is not necessary

No longer available for download until changes are made

As usual, if you want something more professional and more versatile take a look to Christian’s plugins.

How do you handle the thread safety?

And if you have MBS Xojo Plugins, check SignalHandlerMBS class.

I’m not sure what you mean by ‘How do you handle the thread safety?’

The signal handler raise an event every time a signal arrives. I did a simulation on two days by sending a signal every 30 secs while the application did its job normally without encountering any problem/crash

If you think is not safer than calling back directly Xojo code I will remove this plugin from the download immediately.

Yes I have an active license of your plugins but unless you agree to disclose source code of SignalHandlerMBS class as mentioned by the application specifications I can’t use it

The problem is that signals may not arrive at the main thread. Calling a Xojo method in that case causes trouble. We avoid that usually by setting a flag and checking that in Xojo in a timer to react to it in a timely manner.

If clients need source code for escrow/backup, they can ask for that, but it has a price.

Thanks for the advice Christian. To summarize within the signal handler I set up a flag and a background task will check on a regular basis if this flag is true and then raise the event if necessary. Right ?

I’ll make modification accordingly. In the meantime download will be disabled

This project is for an association. I doubt they want to spend any more money than they have to but I can ask

Sounds fine.

New version is available here

Could someone test it on an Mac ARM ? I don’t have this type of machine and I’m stuck with Xojo 2020 r1.2. Thanks in advance